mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-28 14:36:34 +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 llvm-svn: 52275
This commit is contained in:
parent
327c3e7559
commit
f66a7fe9de
@ -185,14 +185,21 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
|
||||
Loop *InsertPtLoop = LI.getLoopFor(MulInsertPt->getParent());
|
||||
if (InsertPtLoop != L && InsertPtLoop &&
|
||||
L->contains(InsertPtLoop->getHeader())) {
|
||||
while (InsertPtLoop != L) {
|
||||
do {
|
||||
// If we cannot hoist the multiply out of this loop, don't.
|
||||
if (!InsertPtLoop->isLoopInvariant(F)) break;
|
||||
|
||||
// Otherwise, move the insert point to the preheader of the loop.
|
||||
MulInsertPt = InsertPtLoop->getLoopPreheader()->getTerminator();
|
||||
BasicBlock *InsertPtLoopPH = InsertPtLoop->getLoopPreheader();
|
||||
|
||||
// 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();
|
||||
}
|
||||
} while (InsertPtLoop != L);
|
||||
}
|
||||
|
||||
return InsertBinop(Instruction::Mul, I, F, MulInsertPt);
|
||||
|
Loading…
Reference in New Issue
Block a user