diff options
Diffstat (limited to 'lib/Transforms/Scalar/FastDSE.cpp')
-rw-r--r-- | lib/Transforms/Scalar/FastDSE.cpp | 36 |
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); + } } } |