diff options
author | Devang Patel <dpatel@apple.com> | 2008-07-09 00:12:01 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-07-09 00:12:01 +0000 |
commit | 51cbf928ab5d77ad4368a01d4e7470dbaa05ae21 (patch) | |
tree | 356fcf3344392dae7b70f2a3c6236cc6b458468d /llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp | |
parent | 919936815ed9b3295b630f3c5821354d118d4cf6 (diff) | |
download | bcm5719-llvm-51cbf928ab5d77ad4368a01d4e7470dbaa05ae21.tar.gz bcm5719-llvm-51cbf928ab5d77ad4368a01d4e7470dbaa05ae21.zip |
If loop induction variable's start value is less then its exit value then do not split the loop.
llvm-svn: 53265
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp index 45d4900ca86..135ce33ee6f 100644 --- a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp @@ -384,6 +384,19 @@ void LoopIndexSplit::findLoopConditionals() { BasicBlock *Preheader = L->getLoopPreheader(); StartValue = IndVar->getIncomingValueForBlock(Preheader); } + + // If start value is more then exit value where induction variable + // increments by 1 then we are potentially dealing with an infinite loop. + // Do not index split this loop. + if (ExitCondition) { + ConstantInt *SV = dyn_cast<ConstantInt>(StartValue); + ConstantInt *EV = + dyn_cast<ConstantInt>(ExitCondition->getOperand(ExitValueNum)); + if (SV && EV && SV->getSExtValue() > EV->getSExtValue()) + ExitCondition = NULL; + else if (EV && EV->isZero()) + ExitCondition = NULL; + } } /// Find condition inside a loop that is suitable candidate for index split. |