Skip to content

Commit

Permalink
terminate circuit on qcs.synchronize
Browse files Browse the repository at this point in the history
  • Loading branch information
bcdonovan committed Mar 27, 2024
1 parent e0b4a85 commit cddda9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Dialect/QUIR/Transforms/ExtractCircuits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ llvm::cl::opt<bool>
static bool terminatesCircuit(Operation &op) {
return (op.hasTrait<::mlir::RegionBranchOpInterface::Trait>() ||
isa<qcs::ParallelControlFlowOp>(op) ||
isa<oq3::CBitInsertBitOp>(op) || isa<quir::SwitchOp>(op));
isa<oq3::CBitInsertBitOp>(op) || isa<quir::SwitchOp>(op) ||
isa<qcs::SynchronizeOp>(op));
} // terminatesCircuit

OpBuilder ExtractCircuitsPass::startCircuit(Location location,
Expand Down
7 changes: 7 additions & 0 deletions test/Dialect/QUIR/Transforms/extract-circuits.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ module {
scf.yield
// CHECK: scf.yield
}
%5 = quir.measure(%0) : (!quir.qubit<1>) -> (i1)
// CHECK: %5 = quir.call_circuit @circuit_6(%0) : (!quir.qubit<1>) -> i1
// CHECK-NOT: %5 = quir.measure(%0) : (!quir.qubit<1>) -> (i1)
qcs.synchronize %0 : (!quir.qubit<1>) -> ()
%6 = quir.measure(%0) : (!quir.qubit<1>) -> (i1)
// CHECK: %6 = quir.call_circuit @circuit_7(%0) : (!quir.qubit<1>) -> i1
// CHECK-NOT: %6 = quir.measure(%0) : (!quir.qubit<1>) -> (i1)
} {qcs.shot_loop, quir.classicalOnly = false, quir.physicalIds = [0 : i32, 1 : i32, 2 : i32]}
qcs.finalize
return %c0_i32 : i32
Expand Down

0 comments on commit cddda9c

Please sign in to comment.