aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/LoopIndexSplit.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2008-07-09 00:12:01 +0000
committerDevang Patel <dpatel@apple.com>2008-07-09 00:12:01 +0000
commita5e27f80282d240817d651347a2ddc80a03ee9ce (patch)
tree0c1a948a5e7011c4dc585f2d72e848dd6fa681ec /lib/Transforms/Scalar/LoopIndexSplit.cpp
parentf877b735ad4987f26cafcbaf22aa4c2199458b5d (diff)
downloadexternal_llvm-a5e27f80282d240817d651347a2ddc80a03ee9ce.zip
external_llvm-a5e27f80282d240817d651347a2ddc80a03ee9ce.tar.gz
external_llvm-a5e27f80282d240817d651347a2ddc80a03ee9ce.tar.bz2
If loop induction variable's start value is less then its exit value then do not split the loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53265 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopIndexSplit.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopIndexSplit.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp
index 45d4900..135ce33 100644
--- a/lib/Transforms/Scalar/LoopIndexSplit.cpp
+++ b/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.