Skip to content

Commit ff90e4f

Browse files
committed
pass block args when inlining CtrlOp
1 parent f7e73a1 commit ff90e4f

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

mlir/lib/Dialect/QC/IR/Modifiers/PowOp.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,12 @@ struct MoveCtrlOutside final : OpRewritePattern<PowOp> {
221221
auto targets = llvm::to_vector(innerCtrl.getTargets());
222222
rewriter.replaceOpWithNewOp<CtrlOp>(
223223
op, controls, targets, [&](ValueRange ctrlArgs) {
224-
// Remap old CtrlOp's block arguments to the new CtrlOp's block
225-
// arguments, since the inlined ops reference them and the old
226-
// CtrlOp is about to be erased with the old PowOp.
227-
for (auto [oldArg, newArg] :
228-
llvm::zip_equal(innerCtrl.getBody()->getArguments(), ctrlArgs)) {
229-
rewriter.replaceAllUsesWith(oldArg, newArg);
230-
}
231224
PowOp::create(rewriter, op.getLoc(), op.getExponentValue(), [&] {
232225
auto* powBody = rewriter.getInsertionBlock();
226+
// Inline the old CtrlOp's body, remapping its block arguments to
227+
// the new CtrlOp's block arguments.
233228
rewriter.inlineBlockBefore(innerCtrl.getBody(), powBody,
234-
powBody->begin());
229+
powBody->begin(), ctrlArgs);
235230
rewriter.eraseOp(&powBody->back()); // erase the inlined YieldOp
236231
});
237232
});

0 commit comments

Comments
 (0)