diff options
author | Devang Patel <dpatel@apple.com> | 2007-09-25 18:24:48 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-09-25 18:24:48 +0000 |
commit | a6dff2faeb78c5020e7ba7f3892873cdd25e6cc4 (patch) | |
tree | 94f206c071266c24a27f59fb6e804506f974dc7e /lib/Transforms/Scalar/LoopIndexSplit.cpp | |
parent | a37c9f7506af622b9f29a35466b33c650c75e9f7 (diff) |
Handle multiple induction variables.
This fixes PR714.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42309 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopIndexSplit.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopIndexSplit.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp index 6582f368a7..5064063f29 100644 --- a/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/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, |