[Mlir-commits] [mlir] [mlir] Avoid rewriting unreachable blocks in the greedy driver (PR #225814)
Renato Golin
llvmlistbot at llvm.org
Wed Sep 30 06:52:05 PDT 2026
================
----------------
rengolin wrote:
What is the use case here?
IIUC, a rewrite replaces op A with B, and A's region is now unreachable (no edges). But later, another rewrite in the same greedy sequence reconnects A into C as a user/consumer? If this is correct, then this feels unsound.
The only time when A should be connected to C like that, as I understand, is when the rewrite "knows what it's doing" and does that _before returning_, so the state of the IR is never _unsound_ between rewrites, which shouldn't affect the greedy patterns.
Another way is when a rewrite matches "all A operations in the function" and then do something with it, including creating a new op K that has edges to it. For example, some annotation op that tracks all "A ops" in the function body.
In the second case, the op A is still _dead_ but annotated. If the K op has execution semantics, then this is an _"unsound transformation"_, right? Is this why you keep them out of the work list?
Is this all to avoid a costly DCE in between rewrites in the greedy pattern?
https://github.com/llvm/llvm-project/pull/225814
More information about the Mlir-commits
mailing list