[Mlir-commits] [mlir] [mlir][Canonicalizer] Preserve analyses when there is no change (PR #232159)

Hideto Ueno llvmlistbot at llvm.org
Wed Oct 14 20:15:30 PDT 2026


https://github.com/uenoku updated https://github.com/llvm/llvm-project/pull/232159

>From dd23d340dc96b9b638e4811644fddf06ae0a9797 Mon Sep 17 00:00:00 2001
From: Hideto Ueno <uenoku.tokotoko at gmail.com>
Date: Wed, 14 Oct 2026 18:48:56 -0700
Subject: [PATCH 1/2] [mlir][Canonicalizer] Preserve analyses when there is no
 change

Assisted-by: pi.dev: gpt 6 luna
---
 mlir/lib/Transforms/Canonicalizer.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mlir/lib/Transforms/Canonicalizer.cpp b/mlir/lib/Transforms/Canonicalizer.cpp
index 83829397adb619..94c9215ff71991 100644
--- a/mlir/lib/Transforms/Canonicalizer.cpp
+++ b/mlir/lib/Transforms/Canonicalizer.cpp
@@ -84,11 +84,14 @@ struct Canonicalizer : public impl::CanonicalizerPassBase<Canonicalizer> {
     return success();
   }
   void runOnOperation() override {
+    bool changed = false;
     LogicalResult converged =
-        applyPatternsGreedily(getOperation(), *patterns, config);
+        applyPatternsGreedily(getOperation(), *patterns, config, &changed);
     // Canonicalization is best-effort. Non-convergence is not a pass failure.
     if (testConvergence && failed(converged))
       signalPassFailure();
+    if (!changed)
+      markAllAnalysesPreserved();
   }
   GreedyRewriteConfig config;
   std::shared_ptr<const FrozenRewritePatternSet> patterns;

>From c3212d122b34022e33601b4f5f8aa1ad3d0127e4 Mon Sep 17 00:00:00 2001
From: Hideto Ueno <uenoku.tokotoko at gmail.com>
Date: Wed, 14 Oct 2026 20:15:03 -0700
Subject: [PATCH 2/2] Update the test

---
 mlir/test/Pass/pass-timing.mlir | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/mlir/test/Pass/pass-timing.mlir b/mlir/test/Pass/pass-timing.mlir
index a383d01c2dc626..e3d8e026795102 100644
--- a/mlir/test/Pass/pass-timing.mlir
+++ b/mlir/test/Pass/pass-timing.mlir
@@ -31,7 +31,6 @@
 // PIPELINE-NEXT:     (A) DominanceInfo
 // PIPELINE-NEXT:   Canonicalizer
 // PIPELINE-NEXT:   CSE
-// PIPELINE-NEXT:     (A) DominanceInfo
 // PIPELINE-NEXT: Output
 // PIPELINE-NEXT: Rest
 // PIPELINE-NEXT: Total
@@ -49,8 +48,6 @@
 // PIPELINE-JSON-NEXT: "name": "CanonicalizerPass", "passes": [
 // PIPELINE-JSON-NEXT: {}]},
 // PIPELINE-JSON-NEXT: "name": "CSEPass", "passes": [
-// PIPELINE-JSON-NEXT: "name": "(A) DominanceInfo", "passes": [
-// PIPELINE-JSON-NEXT: {}]},
 // PIPELINE-JSON-NEXT: {}]},
 // PIPELINE-JSON-NEXT: {}]},
 // PIPELINE-JSON-NEXT: "name": "Output", "passes": [
@@ -75,7 +72,6 @@
 // MT_PIPELINE-NEXT:     (A) DominanceInfo
 // MT_PIPELINE-NEXT:   Canonicalizer
 // MT_PIPELINE-NEXT:   CSE
-// MT_PIPELINE-NEXT:     (A) DominanceInfo
 // MT_PIPELINE-NEXT: Output
 // MT_PIPELINE-NEXT: Rest
 // MT_PIPELINE-NEXT: Total



More information about the Mlir-commits mailing list