Skip to content

Commit 647c063

Browse files
[mlir][SCF] Do not access erased op in scf.while lowering
1 parent f2e244f commit 647c063

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,14 +630,16 @@ DoWhileLowering::matchAndRewrite(WhileOp whileOp,
630630
// Loop around the "before" region based on condition.
631631
rewriter.setInsertionPointToEnd(before);
632632
auto condOp = cast<ConditionOp>(before->getTerminator());
633-
rewriter.replaceOpWithNewOp<cf::CondBranchOp>(condOp, condOp.getCondition(),
634-
before, condOp.getArgs(),
635-
continuation, ValueRange());
633+
rewriter.create<cf::CondBranchOp>(condOp.getLoc(), condOp.getCondition(),
634+
before, condOp.getArgs(), continuation,
635+
ValueRange());
636636

637637
// Replace the op with values "yielded" from the "before" region, which are
638638
// visible by dominance.
639639
rewriter.replaceOp(whileOp, condOp.getArgs());
640640

641+
// Erase the condition op.
642+
rewriter.eraseOp(condOp);
641643
return success();
642644
}
643645

0 commit comments

Comments
 (0)