[llvm] 4a26abc - [InstCombine][OpaquePtr] Check store type in DSE implementation

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 17 10:03:11 PST 2022


Author: Arthur Eubanks
Date: 2022-02-17T10:01:14-08:00
New Revision: 4a26abc0b9ec426f562b7ac6baa5db3d8636a12f

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

LOG: [InstCombine][OpaquePtr] Check store type in DSE implementation

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
    llvm/test/Transforms/InstCombine/opaque-ptr.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index 756792918dba5..fffef500312f6 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -1395,8 +1395,10 @@ Instruction *InstCombinerImpl::visitStoreInst(StoreInst &SI) {
 
     if (StoreInst *PrevSI = dyn_cast<StoreInst>(BBI)) {
       // Prev store isn't volatile, and stores to the same location?
-      if (PrevSI->isUnordered() && equivalentAddressValues(PrevSI->getOperand(1),
-                                                        SI.getOperand(1))) {
+      if (PrevSI->isUnordered() &&
+          equivalentAddressValues(PrevSI->getOperand(1), SI.getOperand(1)) &&
+          PrevSI->getValueOperand()->getType() ==
+              SI.getValueOperand()->getType()) {
         ++NumDeadStore;
         // Manually add back the original store to the worklist now, so it will
         // be processed after the operands of the removed store, as this may

diff  --git a/llvm/test/Transforms/InstCombine/opaque-ptr.ll b/llvm/test/Transforms/InstCombine/opaque-ptr.ll
index 87326008386d1..1826cfdf43bbb 100644
--- a/llvm/test/Transforms/InstCombine/opaque-ptr.ll
+++ b/llvm/test/Transforms/InstCombine/opaque-ptr.ll
@@ -482,3 +482,14 @@ define ptr @select_of_gep_
diff erent_type(i1 %c, ptr %p) {
   %s = select i1 %c, ptr %gep1, ptr %gep2
   ret ptr %s
 }
+
+define void @dse(ptr %p) {
+; CHECK-LABEL: @dse(
+; CHECK-NEXT:    store i32 0, ptr [[P:%.*]], align 4
+; CHECK-NEXT:    store i8 1, ptr [[P]], align 1
+; CHECK-NEXT:    ret void
+;
+  store i32 0, ptr %p
+  store i8 1, ptr %p
+  ret void
+}


        


More information about the llvm-commits mailing list