diff options
author | Dan Gohman <gohman@apple.com> | 2010-02-17 02:39:31 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-02-17 02:39:31 +0000 |
commit | 9feae9f0de032c66d01d16399a4c5296e38870e3 (patch) | |
tree | 672cc5ad644d4aa174af4d39d9f506508caf621c /lib/Analysis/ScalarEvolutionExpander.cpp | |
parent | 22fb4b2a5708c2987a04a823df98b6f9fda60d0c (diff) |
Fix SCEVExpander's existing PHI reuse checking to recognize the
case where there are loop-invariant instructions somehow left
inside the loop, and in a position where they won't dominate
the IV increment position.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96448 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolutionExpander.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index ccd6d6b277..478d04749e 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -658,6 +658,19 @@ SCEVExpander::getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized, IncV = 0; break; } + // If any of the operands don't dominate the insert position, bail. + // Addrec operands are always loop-invariant, so this can only happen + // if there are instructions which haven't been hoisted. + for (User::op_iterator OI = IncV->op_begin()+1, + OE = IncV->op_end(); OI != OE; ++OI) + if (Instruction *OInst = dyn_cast<Instruction>(OI)) + if (!SE.DT->dominates(OInst, IVIncInsertPos)) { + IncV = 0; + break; + } + if (!IncV) + break; + // Advance to the next instruction. IncV = dyn_cast<Instruction>(IncV->getOperand(0)); if (!IncV) break; |