mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Use LoopInfo's getLoopLatch() instead of doing what it does manualy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66467 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
53f2ae268a
commit
0daeed270b
@ -1599,17 +1599,12 @@ static PHINode *InsertAffinePhi(SCEVHandle Start, SCEVHandle Step,
|
||||
|
||||
BasicBlock *Header = L->getHeader();
|
||||
BasicBlock *Preheader = L->getLoopPreheader();
|
||||
BasicBlock *LatchBlock = L->getLoopLatch();
|
||||
|
||||
PHINode *PN = PHINode::Create(Start->getType(), "lsr.iv", Header->begin());
|
||||
PN->addIncoming(Rewriter.expandCodeFor(Start, Preheader->getTerminator()),
|
||||
Preheader);
|
||||
|
||||
pred_iterator HPI = pred_begin(Header);
|
||||
assert(HPI != pred_end(Header) && "Loop with zero preds???");
|
||||
if (!L->contains(*HPI)) ++HPI;
|
||||
assert(HPI != pred_end(Header) && L->contains(*HPI) &&
|
||||
"No backedge in loop?");
|
||||
|
||||
// If the stride is negative, insert a sub instead of an add for the
|
||||
// increment.
|
||||
bool isNegative = isNonConstantNegative(Step);
|
||||
@ -1622,17 +1617,14 @@ static PHINode *InsertAffinePhi(SCEVHandle Start, SCEVHandle Step,
|
||||
Value *StepV = Rewriter.expandCodeFor(IncAmount, Preheader->getTerminator());
|
||||
if (isNegative) {
|
||||
IncV = BinaryOperator::CreateSub(PN, StepV, "lsr.iv.next",
|
||||
(*HPI)->getTerminator());
|
||||
LatchBlock->getTerminator());
|
||||
} else {
|
||||
IncV = BinaryOperator::CreateAdd(PN, StepV, "lsr.iv.next",
|
||||
(*HPI)->getTerminator());
|
||||
LatchBlock->getTerminator());
|
||||
}
|
||||
if (!isa<ConstantInt>(StepV)) ++NumVariable;
|
||||
|
||||
pred_iterator PI = pred_begin(Header);
|
||||
if (*PI == L->getLoopPreheader())
|
||||
++PI;
|
||||
PN->addIncoming(IncV, *PI);
|
||||
PN->addIncoming(IncV, LatchBlock);
|
||||
|
||||
++NumInserted;
|
||||
return PN;
|
||||
|
Loading…
Reference in New Issue
Block a user