From 1cfa05e66c090ed6b57e7631b4935f2a7f5a6aad Mon Sep 17 00:00:00 2001 From: Hiroshi Horii Date: Tue, 20 Jul 2021 23:43:47 +0900 Subject: [PATCH] fix a bug to generate a diagonal gate in the end of circuit (#1294) --- src/transpile/fusion.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/transpile/fusion.hpp b/src/transpile/fusion.hpp index e5266d6e1d..a8105baed1 100644 --- a/src/transpile/fusion.hpp +++ b/src/transpile/fusion.hpp @@ -658,8 +658,10 @@ bool DiagonalFusion::aggregate_operations(oplist_t& ops, continue; std::vector fusing_op_idxs; - for (; op_idx < next_diagonal_start; ++op_idx) + while(op_idx < next_diagonal_start && op_idx < fusion_end) { fusing_op_idxs.push_back(op_idx); + ++op_idx; + } --op_idx; allocate_new_operation(ops, op_idx, fusing_op_idxs, method, true);