summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-21 07:34:32 +0000
committerChris Lattner <sabre@nondot.org>2010-11-21 07:34:32 +0000
commite48c31ce33d5d033aa9a79f092057d92173a676d (patch)
treec640c676b0ab95a69b4cfd2be27f8228b8d557bb /llvm/lib/Transforms
parent6e22221b377b660e63b617950ca6c4bb04f222e8 (diff)
downloadbcm5719-llvm-e48c31ce33d5d033aa9a79f092057d92173a676d.tar.gz
bcm5719-llvm-e48c31ce33d5d033aa9a79f092057d92173a676d.zip
implement PR8576, deleting dead stores with intervening may-alias stores.
llvm-svn: 119927
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 1ea0b15e4c9..02df1031e60 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -217,9 +217,28 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
continue;
}
- // If not a definite must-alias dependency, ignore it.
- if (!InstDep.isDef())
- continue;
+ if (!InstDep.isDef()) {
+ // If this is a may-aliased store that is clobbering the store value, we
+ // can keep searching past it for another must-aliased pointer that stores
+ // to the same location. For example, in:
+ // store -> P
+ // store -> Q
+ // store -> P
+ // we can remove the first store to P even though we don't know if P and Q
+ // alias.
+ if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
+ AliasAnalysis::Location Loc =
+ getAnalysis<AliasAnalysis>().getLocation(SI);
+ while (InstDep.isClobber() && isa<StoreInst>(InstDep.getInst()) &&
+ InstDep.getInst() != &BB.front())
+ InstDep = MD.getPointerDependencyFrom(Loc, false, InstDep.getInst(),
+ &BB);
+ }
+
+ // If not a definite must-alias dependency, ignore it.
+ if (!InstDep.isDef())
+ continue;
+ }
// If this is a store-store dependence, then the previous store is dead so
// long as this store is at least as big as it.
OpenPOWER on IntegriCloud