aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/FastDSE.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2007-07-16 21:52:50 +0000
committerOwen Anderson <resistor@mac.com>2007-07-16 21:52:50 +0000
commitfaac518ce0ae88a19f26b9aa9d34f6bf86ecb8c4 (patch)
treeec921ad0c2c4ec94bd031b3765b544bdd4b54ce4 /lib/Transforms/Scalar/FastDSE.cpp
parent1629a1fa87f8c32d6d33173d6d6e77dc4ed1ca4f (diff)
Add support for walking up memory def chains, which enables finding many more
dead stores on 400.perlbench. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39929 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/FastDSE.cpp')
-rw-r--r--lib/Transforms/Scalar/FastDSE.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/lib/Transforms/Scalar/FastDSE.cpp b/lib/Transforms/Scalar/FastDSE.cpp
index 901a735e3c..45985ba717 100644
--- a/lib/Transforms/Scalar/FastDSE.cpp
+++ b/lib/Transforms/Scalar/FastDSE.cpp
@@ -119,22 +119,32 @@ bool FDSE::runOnBasicBlock(BasicBlock &BB) {
// ... to a pointer that has been stored to before...
if (last) {
+ Instruction* dep = MD.getDependency(BBI);
+
// ... and no other memory dependencies are between them....
- if (MD.getDependency(BBI) == last) {
-
- // Remove it!
- MD.removeInstruction(last);
+ while (dep != MemoryDependenceAnalysis::None &&
+ dep != MemoryDependenceAnalysis::NonLocal &&
+ isa<StoreInst>(dep)) {
+ if (dep == last) {
+
+ // Remove it!
+ MD.removeInstruction(last);
- // DCE instructions only used to calculate that store
- if (Instruction* D = dyn_cast<Instruction>(last->getOperand(0)))
- possiblyDead.insert(D);
- if (Instruction* D = dyn_cast<Instruction>(last->getOperand(1)))
- possiblyDead.insert(D);
+ // DCE instructions only used to calculate that store
+ if (Instruction* D = dyn_cast<Instruction>(last->getOperand(0)))
+ possiblyDead.insert(D);
+ if (Instruction* D = dyn_cast<Instruction>(last->getOperand(1)))
+ possiblyDead.insert(D);
- last->eraseFromParent();
- NumFastStores++;
- deletedStore = true;
- MadeChange = true;
+ last->eraseFromParent();
+ NumFastStores++;
+ deletedStore = true;
+ MadeChange = true;
+
+ break;
+ } else {
+ dep = MD.getDependency(BBI, dep);
+ }
}
}