aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/LoopIndexSplit.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-12-03 19:17:21 +0000
committerDevang Patel <dpatel@apple.com>2007-12-03 19:17:21 +0000
commit5ffdc56f53eb2cf22daa6d764a8a0fa9f94e440a (patch)
treed984c994c625b4fad095e66e4580f159de335490 /lib/Transforms/Scalar/LoopIndexSplit.cpp
parentc1d848dd11f9ce3fb5956673652430d895891b6a (diff)
downloadexternal_llvm-5ffdc56f53eb2cf22daa6d764a8a0fa9f94e440a.zip
external_llvm-5ffdc56f53eb2cf22daa6d764a8a0fa9f94e440a.tar.gz
external_llvm-5ffdc56f53eb2cf22daa6d764a8a0fa9f94e440a.tar.bz2
If ExitValue operand is also defined in Loop header then
insert new ExitValue after this operand definition. This fixes PR1828. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44539 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopIndexSplit.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopIndexSplit.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp
index 5064063..138e50d 100644
--- a/lib/Transforms/Scalar/LoopIndexSplit.cpp
+++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp
@@ -1330,6 +1330,23 @@ void LoopIndexSplit::calculateLoopBounds(SplitInfo &SD) {
// A_ExitValue = min(SplitValue, OrignalLoopExitValue)
// B_StartValue = max(SplitValue, OriginalLoopStartValue)
Instruction *InsertPt = L->getHeader()->getFirstNonPHI();
+
+ // If ExitValue operand is also defined in Loop header then
+ // insert new ExitValue after this operand definition.
+ if (Instruction *EVN =
+ dyn_cast<Instruction>(ExitCondition->getOperand(ExitValueNum))) {
+ if (!isa<PHINode>(EVN))
+ if (InsertPt->getParent() == EVN->getParent()) {
+ BasicBlock::iterator LHBI = L->getHeader()->begin();
+ BasicBlock::iterator LHBE = L->getHeader()->end();
+ for(;LHBI != LHBE; ++LHBI) {
+ Instruction *I = LHBI;
+ if (I == EVN)
+ break;
+ }
+ InsertPt = ++LHBI;
+ }
+ }
Value *C1 = new ICmpInst(Sign ?
ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
AEV,