aboutsummaryrefslogtreecommitdiff
path: root/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
commitf6f1f062cc8029aa75ca7d0e99fbc1e0b453d07e (patch)
treeaaeabb940e1abda8247927a5003401bd865f3085 /lib/Transforms
parentb7dfb970e60d0e559f9e27e3914a4cbb8e7be5eb (diff)
implement PR8576, deleting dead stores with intervening may-alias stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119927 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/DeadStoreElimination.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 1ea0b15e4c..02df1031e6 100644
--- a/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/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.