mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Change 'while' loop to 'do' loop.
Add a safety measure. It isn't safe to assume in ScalarEvolutionExpander that all loops are in canonical form (but it should be safe for loops that have AddRecs). xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52275 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
507a58ac9b
commit
5d2bc857ec
@ -185,14 +185,21 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
|
|||||||
Loop *InsertPtLoop = LI.getLoopFor(MulInsertPt->getParent());
|
Loop *InsertPtLoop = LI.getLoopFor(MulInsertPt->getParent());
|
||||||
if (InsertPtLoop != L && InsertPtLoop &&
|
if (InsertPtLoop != L && InsertPtLoop &&
|
||||||
L->contains(InsertPtLoop->getHeader())) {
|
L->contains(InsertPtLoop->getHeader())) {
|
||||||
while (InsertPtLoop != L) {
|
do {
|
||||||
// If we cannot hoist the multiply out of this loop, don't.
|
// If we cannot hoist the multiply out of this loop, don't.
|
||||||
if (!InsertPtLoop->isLoopInvariant(F)) break;
|
if (!InsertPtLoop->isLoopInvariant(F)) break;
|
||||||
|
|
||||||
// Otherwise, move the insert point to the preheader of the loop.
|
BasicBlock *InsertPtLoopPH = InsertPtLoop->getLoopPreheader();
|
||||||
MulInsertPt = InsertPtLoop->getLoopPreheader()->getTerminator();
|
|
||||||
|
// If this loop hasn't got a preheader, we aren't able to hoist the
|
||||||
|
// multiply.
|
||||||
|
if (!InsertPtLoopPH)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Otherwise, move the insert point to the preheader.
|
||||||
|
MulInsertPt = InsertPtLoopPH->getTerminator();
|
||||||
InsertPtLoop = InsertPtLoop->getParentLoop();
|
InsertPtLoop = InsertPtLoop->getParentLoop();
|
||||||
}
|
} while (InsertPtLoop != L);
|
||||||
}
|
}
|
||||||
|
|
||||||
return InsertBinop(Instruction::Mul, I, F, MulInsertPt);
|
return InsertBinop(Instruction::Mul, I, F, MulInsertPt);
|
||||||
|
Loading…
Reference in New Issue
Block a user