[Mlir-commits] [mlir] [mlir][CSE] Add remove dominanceInfo to CSE (PR #192279)

lonely eagle llvmlistbot at llvm.org
Wed Apr 15 08:41:24 PDT 2026


https://github.com/linuxlonelyeagle created https://github.com/llvm/llvm-project/pull/192279

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.

>From 69573c72b69d6ab490baee5b377cbb2369b1f854 Mon Sep 17 00:00:00 2001
From: linuxlonelyeagle <2020382038 at qq.com>
Date: Wed, 15 Apr 2026 15:32:42 +0000
Subject: [PATCH] add remove dominanceInfo to cse.

---
 mlir/lib/Transforms/CSE.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

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 &region : 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 &region : op->getRegions())
+      domInfo->invalidate(&region);
     rewriter.eraseOp(op);
+  }
   if (changed)
     *changed = !opsToErase.empty();
 



More information about the Mlir-commits mailing list