Skip to content

Commit 22934e9

Browse files
committed
Don't lift func.Invoke if it's a GateFunction
1 parent 706bdcc commit 22934e9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/bloqade/qasm2/rewrite/split_ifs.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ..dialects.expr.stmts import GateFunction
88

99
# TODO: unify with PR #248
10-
AllowedThenType = SingleQubitGate | TwoQubitCtrlGate | Measure | GateFunction | Reset
10+
AllowedThenType = SingleQubitGate | TwoQubitCtrlGate | Measure | Reset
1111

1212
DontLiftType = AllowedThenType | scf.Yield | func.Return
1313

@@ -22,7 +22,15 @@ def rewrite_Statement(self, node: ir.Statement) -> RewriteResult:
2222
then_stmts = node.then_body.stmts()
2323

2424
# TODO: should we leave QRegGet in?
25-
lift_stmts = [stmt for stmt in then_stmts if not isinstance(stmt, DontLiftType)]
25+
lift_stmts: list[ir.Statement] = []
26+
for stmt in then_stmts:
27+
if isinstance(stmt, DontLiftType):
28+
continue
29+
30+
if isinstance(stmt, func.Invoke) and isinstance(stmt.callee, GateFunction):
31+
continue
32+
33+
lift_stmts.append(stmt)
2634

2735
for stmt in lift_stmts:
2836
stmt.detach()

0 commit comments

Comments
 (0)