aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-03-10 21:42:19 +0000
committerChris Lattner <sabre@nondot.org>2004-03-10 21:42:19 +0000
commitc6b0c4b9e2ba2b86a5ec96f76fcf1f0f281f12a6 (patch)
tree7ee1b56e4f6665ee2f82acf1015b3dd325c2e6a4 /lib
parenta22ef48fee87843f53237a4812a4512e9820bde8 (diff)
downloadexternal_llvm-c6b0c4b9e2ba2b86a5ec96f76fcf1f0f281f12a6.zip
external_llvm-c6b0c4b9e2ba2b86a5ec96f76fcf1f0f281f12a6.tar.gz
external_llvm-c6b0c4b9e2ba2b86a5ec96f76fcf1f0f281f12a6.tar.bz2
Fix PR284: [indvars] Induction variable analysis violates LLVM invariants
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12275 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/InductionVariable.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Analysis/InductionVariable.cpp b/lib/Analysis/InductionVariable.cpp
index b602529..8f62297 100644
--- a/lib/Analysis/InductionVariable.cpp
+++ b/lib/Analysis/InductionVariable.cpp
@@ -136,10 +136,14 @@ InductionVariable::InductionVariable(PHINode *P, LoopInfo *LoopInfo): End(0) {
if (Constant *CV = dyn_cast<Constant>(V))
Step = ConstantExpr::get(Instruction::Sub, Zero, CV);
else if (Instruction *I = dyn_cast<Instruction>(V)) {
+ BasicBlock::iterator InsertPt = I;
+ for (++InsertPt; isa<PHINode>(InsertPt); ++InsertPt)
+ /*empty*/;
Step = BinaryOperator::create(Instruction::Sub, Zero, V,
- V->getName()+".neg", I->getNext());
+ V->getName()+".neg", InsertPt);
} else {
+ // Must be loop invariant
Step = BinaryOperator::create(Instruction::Sub, Zero, V,
V->getName()+".neg",
Phi->getParent()->getParent()->begin()->begin());