mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +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 *Header = L->getHeader();
|
||||||
BasicBlock *Preheader = L->getLoopPreheader();
|
BasicBlock *Preheader = L->getLoopPreheader();
|
||||||
|
BasicBlock *LatchBlock = L->getLoopLatch();
|
||||||
|
|
||||||
PHINode *PN = PHINode::Create(Start->getType(), "lsr.iv", Header->begin());
|
PHINode *PN = PHINode::Create(Start->getType(), "lsr.iv", Header->begin());
|
||||||
PN->addIncoming(Rewriter.expandCodeFor(Start, Preheader->getTerminator()),
|
PN->addIncoming(Rewriter.expandCodeFor(Start, Preheader->getTerminator()),
|
||||||
Preheader);
|
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
|
// If the stride is negative, insert a sub instead of an add for the
|
||||||
// increment.
|
// increment.
|
||||||
bool isNegative = isNonConstantNegative(Step);
|
bool isNegative = isNonConstantNegative(Step);
|
||||||
@ -1622,17 +1617,14 @@ static PHINode *InsertAffinePhi(SCEVHandle Start, SCEVHandle Step,
|
|||||||
Value *StepV = Rewriter.expandCodeFor(IncAmount, Preheader->getTerminator());
|
Value *StepV = Rewriter.expandCodeFor(IncAmount, Preheader->getTerminator());
|
||||||
if (isNegative) {
|
if (isNegative) {
|
||||||
IncV = BinaryOperator::CreateSub(PN, StepV, "lsr.iv.next",
|
IncV = BinaryOperator::CreateSub(PN, StepV, "lsr.iv.next",
|
||||||
(*HPI)->getTerminator());
|
LatchBlock->getTerminator());
|
||||||
} else {
|
} else {
|
||||||
IncV = BinaryOperator::CreateAdd(PN, StepV, "lsr.iv.next",
|
IncV = BinaryOperator::CreateAdd(PN, StepV, "lsr.iv.next",
|
||||||
(*HPI)->getTerminator());
|
LatchBlock->getTerminator());
|
||||||
}
|
}
|
||||||
if (!isa<ConstantInt>(StepV)) ++NumVariable;
|
if (!isa<ConstantInt>(StepV)) ++NumVariable;
|
||||||
|
|
||||||
pred_iterator PI = pred_begin(Header);
|
PN->addIncoming(IncV, LatchBlock);
|
||||||
if (*PI == L->getLoopPreheader())
|
|
||||||
++PI;
|
|
||||||
PN->addIncoming(IncV, *PI);
|
|
||||||
|
|
||||||
++NumInserted;
|
++NumInserted;
|
||||||
return PN;
|
return PN;
|
||||||
|
Loading…
Reference in New Issue
Block a user