[Mlir-commits] [mlir] [mlir] Fix non-termination when a block becomes unreachable during rewriting (PR #221152)
Matthias Springer
llvmlistbot at llvm.org
Fri Sep 11 00:07:14 PDT 2026
================
@@ -482,6 +482,15 @@ bool GreedyPatternRewriteDriver::processWorklist() {
}
});
+ // Folding an operation that uses its own result can loop forever, so
+ // skip it. Such operations are legal in unreachable code.
----------------
matthias-springer wrote:
Two potential directions come to mind:
1. `%0 = arith.addi %0, %c1 : i32` looks invalid to me. We allow it inside of a graph region, but what's the semantics of such an op? Makes me wonder if ops should explicitly have to opt in to being placed inside of a graph region...
2. Patch the canonicalization pattern / folder for `arith.addi`, so that it does not apply when operand and result are the same. But many of these patterns are defined in `ArithCanonicalization.td` and I'm not sure how difficult it is to add such checks.
https://github.com/llvm/llvm-project/pull/221152
More information about the Mlir-commits
mailing list