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 | c70e99436449c145a12c72e4e47252249cf88037 (patch) | |
tree | c4e57e075c97afed48cac623b18c5f20a490e6ed /llvm/lib/Analysis/ScalarEvolutionExpander.cpp | |
parent | 06be9689424283c143959c0f4659d6b5da22f67d (diff) | |
download | bcm5719-llvm-c70e99436449c145a12c72e4e47252249cf88037.tar.gz bcm5719-llvm-c70e99436449c145a12c72e4e47252249cf88037.zip |
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.
llvm-svn: 96448
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolutionExpander.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp index ccd6d6b2778..478d04749e2 100644 --- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/llvm/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; |