[Mlir-commits] [mlir] [mlir][CSE] Pre-process trivially dead ops (NFC) (PR #191135)

lonely eagle llvmlistbot at llvm.org
Fri Apr 17 03:13:26 PDT 2026


================
@@ -308,7 +301,16 @@ LogicalResult CSEDriver::simplifyOperation(ScopedMapTy &knownValues,
 
 void CSEDriver::simplifyBlock(ScopedMapTy &knownValues, Block *bb,
                               bool hasSSADominance) {
-  for (auto &op : *bb) {
+  for (auto &op : llvm::make_early_inc_range(*bb)) {
+    // If the operation is already trivially dead just add it to the erase list.
+    // This also avoids calling `simplifyRegion` on dead region ops
+    // unnecessarily.
+    if (isOpTriviallyDead(&op)) {
----------------
linuxlonelyeagle wrote:

Yes, we `opsToErase.push_back(&op);`, the dominate tree will be remove.

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


More information about the Mlir-commits mailing list