[Mlir-commits] [mlir] [mlir] Optimize `isOpTriviallyDead` greedy rewriter checks for deeply nested IR (PR #231423)

Mehdi Amini llvmlistbot at llvm.org
Tue Oct 13 03:47:07 PDT 2026


================
@@ -36,6 +36,35 @@ bool mlir::isOpTriviallyDead(Operation *op) {
   return op->use_empty() && wouldOpBeTriviallyDead(op);
 }
 
+static bool hasOnlyDeadEffects(Operation *op, bool hasRecursiveEffects) {
+  // If the op has memory effects, characterize them to see if the op can be
+  // trivially dead.
----------------
joker-eph wrote:

Can we lift this to function documentation? I would include a bit more information about what this does:

```
// Return true if the op can be trivially deleted based on its memory effects. An op 
// is considered trivially dead only if it's performing reads or allocating a result. 
// An op that does not define MemoryEffectOpInterface `hasRecursiveEffects`,
// the caller must also check its children. 
```




https://github.com/llvm/llvm-project/pull/231423


More information about the Mlir-commits mailing list