llvm-project
fd01599c - [mlir] Optimize `isOpTriviallyDead` greedy rewriter checks for deeply nested IR (#231423)

Commit
37 days ago
[mlir] Optimize `isOpTriviallyDead` greedy rewriter checks for deeply nested IR (#231423) See the discussion https://github.com/llvm/llvm-project/pull/230961#issuecomment-6130021318 Driver checks `isOpTriviallyDead` after each IR modifications and `isOpTriviallyDead` walked the entire nested chain for `HasRecursiveMemoryEffects`. Cache op deadness in driver and invalidate on IR change. Also, `Operation *dumpRootOp = getDumpRootOp(op);` only needed for debug printing was called unconditionally and was also noticeable in profiler. Call it only if debug printing is actually enabled. Added synthetic 1000-nested IR test, generated by python. Test doesn't actually check execution times, but I hope someone will notice if it suddenly start to take 30s. Times for 1000-nested `scf.for` test on my machine: | 1,000-nested case | Before | After | Speedup | |---|---:|---:|---:| | PR loop-range reproduction | 22.806 s | 0.271 s | 84.1× | | Normal canonicalization stress test | 21.223 s | 1.058 s | 20.1× | Normal MLIR lit test times stayed flat, without obvious regressions. AI assisted, obviously
Author
Parents
Loading