[PATCH] D132657: [DSE] Eliminate noop store even through has clobbering between LoadI and StoreI
luxufan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 1 23:41:22 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd8f3e758139: [DSE] Eliminate noop store even through has clobbering between LoadI and StoreI (authored by StephenFan).
Changed prior to commit:
https://reviews.llvm.org/D132657?vs=456840&id=457512#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132657/new/
https://reviews.llvm.org/D132657
Files:
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll
Index: llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll
===================================================================
--- llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll
+++ llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll
@@ -612,12 +612,10 @@
; 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
}
Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1864,8 +1864,16 @@
// 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)
+ 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;
+ }
return false;
+ }
}
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132657.457512.patch
Type: text/x-patch
Size: 1690 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220902/4afc5b54/attachment.bin>
More information about the llvm-commits
mailing list