[flang-commits] [flang] [mlir] [mlir][CSE] Add pruneDeadOps to CSE pass (PR #193778)

Mehdi Amini via flang-commits flang-commits at lists.llvm.org
Sat May 2 10:56:23 PDT 2026


================
@@ -294,15 +297,38 @@ LogicalResult CSEDriver::simplifyOperation(ScopedMapTy &knownValues,
   return failure();
 }
 
+void CSEDriver::pruneDeadOps(Operation *root, ScopedMapTy &knownValues) {
+  // We use `SetVector` to prevent already inserted ops from being added to the
+  // `worklist` repeatedly, avoiding secondary access to erased operations.
+  llvm::SetVector<Operation *> worklist;
----------------
joker-eph wrote:

Why do you think it makes sense? Do you have a case not covered by applying a trivial DCE before CSE? That is one example for my previous question:  is there a case where a DCE opportunity only presents itself after CSE merged some operations?

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


More information about the flang-commits mailing list