diff --git a/mlir/lib/Dialect/Arith/Transforms/IntRangeOptimizations.cpp b/mlir/lib/Dialect/Arith/Transforms/IntRangeOptimizations.cpp index fefbba989b996..9f849ac4980d6 100644 --- a/mlir/lib/Dialect/Arith/Transforms/IntRangeOptimizations.cpp +++ b/mlir/lib/Dialect/Arith/Transforms/IntRangeOptimizations.cpp @@ -676,9 +676,14 @@ struct IntRangeOptimizationsPass final RewritePatternSet patterns(ctx); populateIntRangeOptimizationsPatterns(patterns, solver); + // Disable folding to avoid potential control-flow folding that would break + // the solver state: this happens for example when a block argument is + // folded and other block arguments inherit from the address of the folded + // block argument. Further queries to the remaining block arguments would + // then return the solver state associated to the original block argument. if (failed(applyPatternsGreedily( op, std::move(patterns), - GreedyRewriteConfig().setListener(&listener)))) + GreedyRewriteConfig().enableFolding(false).setListener(&listener)))) signalPassFailure(); } };