diff options
| author | Dan Gohman <gohman@apple.com> | 2009-05-03 05:46:20 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2009-05-03 05:46:20 +0000 |
| commit | 5036695c32835ad0fb280b9d20f9214f5270dfb0 (patch) | |
| tree | 611a881c018a3620022de19c72bd293785cf274c /llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | |
| parent | 7d79a5f87dcd6ab25607315c894325088949b299 (diff) | |
| download | bcm5719-llvm-5036695c32835ad0fb280b9d20f9214f5270dfb0.tar.gz bcm5719-llvm-5036695c32835ad0fb280b9d20f9214f5270dfb0.zip | |
Revert r70645 for now; it's causing a variety of regressions.
llvm-svn: 70661
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 7d69dc83339..b9406651525 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -253,6 +253,8 @@ void LoopStrengthReduce::DeleteTriviallyDeadInstructions() { if (I == 0 || !isInstructionTriviallyDead(I)) continue; + SE->deleteValueFromRecords(I); + for (User::op_iterator OI = I->op_begin(), E = I->op_end(); OI != E; ++OI) { if (Instruction *U = dyn_cast<Instruction>(*OI)) { *OI = 0; @@ -2128,6 +2130,7 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond, // Remove the old compare instruction. The old indvar is probably dead too. DeadInsts.push_back(cast<Instruction>(CondUse->OperandValToReplace)); + SE->deleteValueFromRecords(OldCond); OldCond->replaceAllUsesWith(Cond); OldCond->eraseFromParent(); @@ -2248,12 +2251,16 @@ ICmpInst *LoopStrengthReduce::OptimizeSMax(Loop *L, ICmpInst *Cond, Cond->getOperand(0), NewRHS, "scmp", Cond); // Delete the max calculation instructions. + SE->deleteValueFromRecords(Cond); Cond->replaceAllUsesWith(NewCond); Cond->eraseFromParent(); Instruction *Cmp = cast<Instruction>(Sel->getOperand(0)); + SE->deleteValueFromRecords(Sel); Sel->eraseFromParent(); - if (Cmp->use_empty()) + if (Cmp->use_empty()) { + SE->deleteValueFromRecords(Cmp); Cmp->eraseFromParent(); + } CondUse->User = NewCond; return NewCond; } @@ -2360,6 +2367,7 @@ void LoopStrengthReduce::OptimizeShadowIV(Loop *L) { NewPH->addIncoming(NewIncr, PH->getIncomingBlock(Latch)); /* Remove cast operation */ + SE->deleteValueFromRecords(ShadowUse); ShadowUse->replaceAllUsesWith(NewPH); ShadowUse->eraseFromParent(); SI->second.Users.erase(CandidateUI); @@ -2499,8 +2507,17 @@ bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager &LPM) { DeleteTriviallyDeadInstructions(); // At this point, it is worth checking to see if any recurrence PHIs are also - // dead, so that we can remove them as well. - DeleteDeadPHIs(L->getHeader()); + // dead, so that we can remove them as well. To keep ScalarEvolution + // current, use a ValueDeletionListener class. + struct LSRListener : public ValueDeletionListener { + ScalarEvolution &SE; + explicit LSRListener(ScalarEvolution &se) : SE(se) {} + + virtual void ValueWillBeDeleted(Value *V) { + SE.deleteValueFromRecords(V); + } + } VDL(*SE); + DeleteDeadPHIs(L->getHeader(), &VDL); return Changed; } |

