[Mlir-commits] [mlir] [mlir] Add option to run CSE between greedy rewriter iterations (PR #193081)
Hocky Yudhiono
llvmlistbot at llvm.org
Tue Apr 21 03:07:26 PDT 2026
================
@@ -899,6 +901,15 @@ LogicalResult RegionPatternRewriteDriver::simplify(bool *changed) && {
}
},
{®ion}, iteration);
+
+ // Optionally run full CSE between iterations. If CSE changes the IR we
+ // iterate again so that patterns can fire on the deduplicated operations.
+ if (config.isCSEBetweenIterationsEnabled()) {
+ DominanceInfo domInfo(region.getParentOp());
+ bool cseChanged = false;
+ eliminateCommonSubExpressions(rewriter, domInfo, region, &cseChanged);
+ continueRewrites |= cseChanged;
+ }
----------------
hockyy wrote:
https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h#L167
Based on this docs:
```
/// Only in-scope ops are added to the
/// worklist and only in-scope ops are allowed to be modified by the patterns.
```
Technically CSE'ing would remove and modify out-of-scope ops(?) Because CSE would call the replaced/erase notifier right?
https://github.com/llvm/llvm-project/pull/193081
More information about the Mlir-commits
mailing list