[Mlir-commits] [mlir] [mlir][Transforms] Greedy pattern rewriter: fix infinite folding loop (PR #161145)
Mehdi Amini
llvmlistbot at llvm.org
Mon Sep 29 01:41:58 PDT 2025
================
@@ -1248,3 +1248,12 @@ func.func @test_materialize_failure() -> i64 {
%u = index.castu %const : index to i64
return %u: i64
}
+
+// -----
+
+// Make sure that the canonicalizer does not fold infinitely.
+
+// CHECK: %[[c0:.*]] = arith.constant 0 : index
+%c0 = arith.constant 0 : index
+// CHECK: %[[add:.*]] = arith.addi %[[c0]], %[[add]] : index
+%0 = arith.addi %c0, %0 : index
----------------
joker-eph wrote:
```suggestion
%0 = arith.addi %0, %c0 : index
```
That's more direct (no need for a first folder moving the constant to the right)
https://github.com/llvm/llvm-project/pull/161145
More information about the Mlir-commits
mailing list