[Mlir-commits] [mlir] [mlir][CSE] Add remove dominanceInfo to CSE (PR #192279)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Apr 15 08:41:59 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: lonely eagle (linuxlonelyeagle)
<details>
<summary>Changes</summary>
The CSE pass calls `markAnalysesPreserved<DominanceInfo, PostDominanceInfo>()` at the end. While CSE erases operations, it does not remove their corresponding dominator trees, causing them to be unnecessarily preserved in memory. This PR addresses the issue by explicitly calling invalidate within CSE to clean up the dominator trees for those erased operations.
---
Full diff: https://github.com/llvm/llvm-project/pull/192279.diff
1 Files Affected:
- (modified) mlir/lib/Transforms/CSE.cpp (+6-2)
``````````diff
diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp
index 4d25e5e7c92b6..fbd9e45cc1955 100644
--- a/mlir/lib/Transforms/CSE.cpp
+++ b/mlir/lib/Transforms/CSE.cpp
@@ -394,9 +394,13 @@ void CSEDriver::simplify(Operation *op, bool *changed) {
for (auto ®ion : op->getRegions())
simplifyRegion(knownValues, region);
- /// Erase any operations that were marked as dead during simplification.
- for (auto *op : opsToErase)
+ /// Erase any operations that were marked as dead during simplification, and
+ /// remove their associated dominator trees.
+ for (auto *op : opsToErase) {
+ for (Region ®ion : op->getRegions())
+ domInfo->invalidate(®ion);
rewriter.eraseOp(op);
+ }
if (changed)
*changed = !opsToErase.empty();
``````````
</details>
https://github.com/llvm/llvm-project/pull/192279
More information about the Mlir-commits
mailing list