diff options
author | Devang Patel <dpatel@apple.com> | 2007-12-03 19:17:21 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-12-03 19:17:21 +0000 |
commit | 5ffdc56f53eb2cf22daa6d764a8a0fa9f94e440a (patch) | |
tree | d984c994c625b4fad095e66e4580f159de335490 /lib | |
parent | c1d848dd11f9ce3fb5956673652430d895891b6a (diff) |
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')
-rw-r--r-- | lib/Transforms/Scalar/LoopIndexSplit.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp index 5064063f29..138e50d8a1 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, |