Commit 8e99a0d9 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Fixing a bug in QPE: integer power within a while loop



The yield op must be inserted at the exit block if created.

Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 5da2e3a7
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -621,8 +621,13 @@ void qasm3_visitor::createWhileLoop(
  // 'After' block must end with a yield op.
  {
    mlir::OpBuilder::InsertionGuard g(builder);
    if (auto b = symbol_table.get_last_created_block()) {
      builder.setInsertionPointToEnd(b);
      symbol_table.set_last_created_block(nullptr);
    } else {
      mlir::Operation &lastOp = whileOp.after().front().getOperations().back();
      builder.setInsertionPointAfter(&lastOp);
    }
    builder.create<mlir::scf::YieldOp>(location);
  }