diff options
author | Dan Gohman <gohman@apple.com> | 2010-02-12 10:34:29 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-02-12 10:34:29 +0000 |
commit | 45774ce0ada1d386c4f338c057f74a3fb2b48efd (patch) | |
tree | 7a7381d527967385658fa0d399fb93483827c1e1 /llvm/lib/Analysis/ScalarEvolutionExpander.cpp | |
parent | c7ef4cc9fcb5e91c0f402e9dc6c85f8357f2cbfc (diff) | |
download | bcm5719-llvm-45774ce0ada1d386c4f338c057f74a3fb2b48efd.tar.gz bcm5719-llvm-45774ce0ada1d386c4f338c057f74a3fb2b48efd.zip |
Reapply the new LoopStrengthReduction code, with compile time and
bug fixes, and with improved heuristics for analyzing foreign-loop
addrecs.
This change also flattens IVUsers, eliminating the stride-oriented
groupings, which makes it easier to work with.
llvm-svn: 95975
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolutionExpander.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp index 4310e3ccfad..9439d084c49 100644 --- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp @@ -641,8 +641,24 @@ SCEVExpander::getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized, // Reuse a previously-inserted PHI, if present. for (BasicBlock::iterator I = L->getHeader()->begin(); PHINode *PN = dyn_cast<PHINode>(I); ++I) - if (isInsertedInstruction(PN) && SE.getSCEV(PN) == Normalized) - return PN; + if (SE.isSCEVable(PN->getType()) && + (SE.getEffectiveSCEVType(PN->getType()) == + SE.getEffectiveSCEVType(Normalized->getType())) && + SE.getSCEV(PN) == Normalized) + if (BasicBlock *LatchBlock = L->getLoopLatch()) { + // Remember this PHI, even in post-inc mode. + InsertedValues.insert(PN); + // Remember the increment. + Instruction *IncV = + cast<Instruction>(PN->getIncomingValueForBlock(LatchBlock) + ->stripPointerCasts()); + rememberInstruction(IncV); + // Make sure the increment is where we want it. But don't move it + // down past a potential existing post-inc user. + if (L == IVIncInsertLoop && !SE.DT->dominates(IncV, IVIncInsertPos)) + IncV->moveBefore(IVIncInsertPos); + return PN; + } // Save the original insertion point so we can restore it when we're done. BasicBlock *SaveInsertBB = Builder.GetInsertBlock(); |