[llvm] r323759 - [DSE] make sure memory is not modified before partial store merging (PR36129)
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 30 05:53:59 PST 2018
Author: spatel
Date: Tue Jan 30 05:53:59 2018
New Revision: 323759
URL: http://llvm.org/viewvc/llvm-project?rev=323759&view=rev
Log:
[DSE] make sure memory is not modified before partial store merging (PR36129)
We missed a critical check in D30703. We must make sure that no intermediate
store is sitting between the stores that we want to merge.
This should fix:
https://bugs.llvm.org/show_bug.cgi?id=36129
Differential Revision: https://reviews.llvm.org/D42663
Modified:
llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/trunk/test/Transforms/DeadStoreElimination/merge-stores.ll
Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=323759&r1=323758&r2=323759&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Tue Jan 30 05:53:59 2018
@@ -1172,7 +1172,8 @@ static bool eliminateDeadStores(BasicBlo
auto *Earlier = dyn_cast<StoreInst>(DepWrite);
auto *Later = dyn_cast<StoreInst>(Inst);
if (Earlier && isa<ConstantInt>(Earlier->getValueOperand()) &&
- Later && isa<ConstantInt>(Later->getValueOperand())) {
+ Later && isa<ConstantInt>(Later->getValueOperand()) &&
+ memoryIsNotModifiedBetween(Earlier, Later, AA)) {
// If the store we find is:
// a) partially overwritten by the store to 'Loc'
// b) the later store is fully contained in the earlier one and
Modified: llvm/trunk/test/Transforms/DeadStoreElimination/merge-stores.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/merge-stores.ll?rev=323759&r1=323758&r2=323759&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/DeadStoreElimination/merge-stores.ll (original)
+++ llvm/trunk/test/Transforms/DeadStoreElimination/merge-stores.ll Tue Jan 30 05:53:59 2018
@@ -186,12 +186,14 @@ define void @PR34074(i32* %x, i64* %y) {
ret void
}
-; FIXME: We can't eliminate the last store because P and Q may alias.
+; We can't eliminate the last store because P and Q may alias.
define void @PR36129(i32* %P, i32* %Q) {
; CHECK-LABEL: @PR36129(
-; CHECK-NEXT: store i32 3, i32* [[P:%.*]]
+; CHECK-NEXT: store i32 1, i32* [[P:%.*]]
+; CHECK-NEXT: [[P2:%.*]] = bitcast i32* [[P]] to i8*
; CHECK-NEXT: store i32 2, i32* [[Q:%.*]]
+; CHECK-NEXT: store i8 3, i8* [[P2]]
; CHECK-NEXT: ret void
;
store i32 1, i32* %P
More information about the llvm-commits
mailing list