[llvm] c453e5b - Revert "[DSE] Eliminate noop store even through has clobbering between LoadI and StoreI"

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 2 00:30:07 PDT 2022


Author: Nikita Popov
Date: 2022-09-02T09:28:48+02:00
New Revision: c453e5b901ccaf9e7102575d6b14f190acc703be

URL: https://github.com/llvm/llvm-project/commit/c453e5b901ccaf9e7102575d6b14f190acc703be
DIFF: https://github.com/llvm/llvm-project/commit/c453e5b901ccaf9e7102575d6b14f190acc703be.diff

LOG: Revert "[DSE] Eliminate noop store even through has clobbering between LoadI and StoreI"

This reverts commit cd8f3e75813995c1d2da35370ffcf5af3aff9c2f.

As pointed out by Eli on the review, this is missing an alignment
check. The value might be written at an offset.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
    llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index d24c5a25abf61..45c404a140af3 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1864,16 +1864,8 @@ struct DSEState {
           // We are searching for the definition of the store's destination.
           // So, if that is the same definition as the load, then this is a
           // noop. Otherwise, fail.
-          if (LoadAccess != Current) {
-            auto *CurrentStoreI =
-                dyn_cast<StoreInst>(cast<MemoryDef>(Current)->getMemoryInst());
-            if (CurrentStoreI && CurrentStoreI->getOperand(0) == LoadI) {
-              // This is a potentially clobbering store, but it writes the same value,
-              // so we can safely ignore it.
-              continue;
-            }
+          if (LoadAccess != Current)
             return false;
-          }
         }
         return true;
       }

diff  --git a/llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll b/llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll
index 06a5f8690c26a..e5630cca1aba5 100644
--- a/llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll
@@ -612,10 +612,12 @@ define void @pr49927(i32* %q, i32* %p) {
 ; CHECK-LABEL: @pr49927(
 ; CHECK-NEXT:    [[V:%.*]] = load i32, i32* [[P:%.*]], align 4
 ; CHECK-NEXT:    store i32 [[V]], i32* [[Q:%.*]], align 4
+; CHECK-NEXT:    store i32 [[V]], i32* [[P]], align 4
 ; CHECK-NEXT:    ret void
 ;
   %v = load i32, i32* %p, align 4
   store i32 %v, i32* %q, align 4
+  ; FIXME: this store can be eliminated
   store i32 %v, i32* %p, align 4
   ret void
 }


        


More information about the llvm-commits mailing list