summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-09-25 18:24:48 +0000
committerDevang Patel <dpatel@apple.com>2007-09-25 18:24:48 +0000
commit7bba386f729690d15d3150a82039798d2042001f (patch)
tree8b81ded0323b5910ce0540e6ed27ee7c42f70a08 /llvm/lib/Transforms
parent31599685c77b74a0c1b5546651b32e1cdc85abd4 (diff)
downloadbcm5719-llvm-7bba386f729690d15d3150a82039798d2042001f.tar.gz
bcm5719-llvm-7bba386f729690d15d3150a82039798d2042001f.zip
Handle multiple induction variables.
This fixes PR714. llvm-svn: 42309
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp
index 6582f368a73..5064063f29a 100644
--- a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp
@@ -676,7 +676,7 @@ bool LoopIndexSplit::safeExitingBlock(SplitInfo &SD,
continue;
// Check if I is induction variable increment instruction.
- if (!IndVarIncrement && I->getOpcode() == Instruction::Add) {
+ if (I->getOpcode() == Instruction::Add) {
Value *Op0 = I->getOperand(0);
Value *Op1 = I->getOperand(1);
@@ -685,16 +685,23 @@ bool LoopIndexSplit::safeExitingBlock(SplitInfo &SD,
if ((PN = dyn_cast<PHINode>(Op0))) {
if ((CI = dyn_cast<ConstantInt>(Op1)))
- IndVarIncrement = I;
+ if (CI->isOne()) {
+ if (!IndVarIncrement && PN == IndVar)
+ IndVarIncrement = I;
+ // else this is another loop induction variable
+ continue;
+ }
} else
if ((PN = dyn_cast<PHINode>(Op1))) {
if ((CI = dyn_cast<ConstantInt>(Op0)))
- IndVarIncrement = I;
+ if (CI->isOne()) {
+ if (!IndVarIncrement && PN == IndVar)
+ IndVarIncrement = I;
+ // else this is another loop induction variable
+ continue;
+ }
}
-
- if (IndVarIncrement && PN == IndVar && CI->isOne())
- continue;
- }
+ }
// I is an Exit condition if next instruction is block terminator.
// Exit condition is OK if it compares loop invariant exit value,
OpenPOWER on IntegriCloud