System and Environment Information
- clang/mlir/llvm version 22.1.0-rc3
- OS: NixOS 26.05 (Yarara), kernel 6.19.10-cachyos, x86_64
- MQT Core: main (54c3016)
Bug Description
Folds on QCO operations (e.g. POp::fold) are not aware that the op may live inside a modifier body (e.g. qco.ctrl). When a fold reduces the op to identity, the modifier body is left containing only qco.yield - an unexpected state, causing a crash.
Steps to Reproduce
Try to compile this with mqt-cc (will segfault):
module {
func.func @controlled-zero-phase() {
%ctrl = qco.alloc : !qco.qubit
%tgt = qco.alloc : !qco.qubit
%cst = arith.constant 0.0 : f64
%ctrl_1, %tgt_1 = qco.ctrl(%ctrl) targets(%t = %tgt) {
%t_1 = qco.p(%cst) %t : !qco.qubit -> !qco.qubit
qco.yield %t_1
} : ({!qco.qubit}, {!qco.qubit}) -> ({!qco.qubit}, {!qco.qubit})
qco.sink %ctrl_1 : !qco.qubit
qco.sink %tgt_1 : !qco.qubit
return
}
}
System and Environment Information
Bug Description
Folds on QCO operations (e.g.
POp::fold) are not aware that the op may live inside a modifier body (e.g.qco.ctrl). When a fold reduces the op to identity, the modifier body is left containing onlyqco.yield- an unexpected state, causing a crash.Steps to Reproduce
Try to compile this with
mqt-cc(will segfault):