Skip to content

Commit d7704af

Browse files
authored
[mlir] fix maybeReplaceWithConstant in IntRangeOptimizations
1 parent f8ffbae commit d7704af

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mlir/lib/Dialect/Arith/Transforms/IntRangeOptimizations.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ LogicalResult maybeReplaceWithConstant(DataFlowSolver &solver,
9191
if (!constOp)
9292
return failure();
9393

94-
copyIntegerRange(solver, value, constOp->getResult(0));
95-
rewriter.replaceAllUsesWith(value, constOp->getResult(0));
94+
OpResult res = constOp->getResult(0);
95+
if (solver.lookupState<dataflow::IntegerValueRangeLattice>(res))
96+
solver.eraseState(res);
97+
copyIntegerRange(solver, value, res);
98+
rewriter.replaceAllUsesWith(value, res);
9699
return success();
97100
}
98101
} // namespace mlir::dataflow

0 commit comments

Comments
 (0)