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
This commit is contained in:
Devang Patel
2007-12-03 19:17:21 +00:00
parent c1d848dd11
commit 5ffdc56f53
2 changed files with 61 additions and 0 deletions

View File

@ -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,