[llvm] [DeadStoreElimination] Optimize tautological assignments (PR #75744)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 06:04:08 PST 2023


================
@@ -1926,6 +1926,43 @@ struct DSEState {
       if (InitC && InitC == StoredConstant)
         return MSSA.isLiveOnEntryDef(
             MSSA.getSkipSelfWalker()->getClobberingMemoryAccess(Def, BatchAA));
+
+      if (!Store)
+        return false;
+
+      // If there is a dominating condition, that ensures that the value
+      // being stored in a memory location is already present at the
+      // memory location, the store is a noop.
+      BasicBlock *StoreBB = DefI->getParent();
+      auto *StorePtr = Store->getOperand(1);
----------------
nikic wrote:

```suggestion
      Value *StorePtr = Store->getPointerOperand();
```

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


More information about the llvm-commits mailing list