forked from OSchip/llvm-project
Allow NULL LoopPassManager argument in UnrollLoop. PR12734.
llvm-svn: 156358
This commit is contained in:
parent
9f5616a005
commit
d29cd732d4
|
@ -204,9 +204,11 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
|
||||||
|
|
||||||
// Notify ScalarEvolution that the loop will be substantially changed,
|
// Notify ScalarEvolution that the loop will be substantially changed,
|
||||||
// if not outright eliminated.
|
// if not outright eliminated.
|
||||||
ScalarEvolution *SE = LPM->getAnalysisIfAvailable<ScalarEvolution>();
|
if (LPM) {
|
||||||
if (SE)
|
ScalarEvolution *SE = LPM->getAnalysisIfAvailable<ScalarEvolution>();
|
||||||
SE->forgetLoop(L);
|
if (SE)
|
||||||
|
SE->forgetLoop(L);
|
||||||
|
}
|
||||||
|
|
||||||
// If we know the trip count, we know the multiple...
|
// If we know the trip count, we know the multiple...
|
||||||
unsigned BreakoutTrip = 0;
|
unsigned BreakoutTrip = 0;
|
||||||
|
@ -405,24 +407,26 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Reconstruct dom info, because it is not preserved properly.
|
if (LPM) {
|
||||||
// Incrementally updating domtree after loop unrolling would be easy.
|
// FIXME: Reconstruct dom info, because it is not preserved properly.
|
||||||
if (DominatorTree *DT = LPM->getAnalysisIfAvailable<DominatorTree>())
|
// Incrementally updating domtree after loop unrolling would be easy.
|
||||||
DT->runOnFunction(*L->getHeader()->getParent());
|
if (DominatorTree *DT = LPM->getAnalysisIfAvailable<DominatorTree>())
|
||||||
|
DT->runOnFunction(*L->getHeader()->getParent());
|
||||||
|
|
||||||
// Simplify any new induction variables in the partially unrolled loop.
|
// Simplify any new induction variables in the partially unrolled loop.
|
||||||
if (SE && !CompletelyUnroll) {
|
ScalarEvolution *SE = LPM->getAnalysisIfAvailable<ScalarEvolution>();
|
||||||
SmallVector<WeakVH, 16> DeadInsts;
|
if (SE && !CompletelyUnroll) {
|
||||||
simplifyLoopIVs(L, SE, LPM, DeadInsts);
|
SmallVector<WeakVH, 16> DeadInsts;
|
||||||
|
simplifyLoopIVs(L, SE, LPM, DeadInsts);
|
||||||
|
|
||||||
// Aggressively clean up dead instructions that simplifyLoopIVs already
|
// Aggressively clean up dead instructions that simplifyLoopIVs already
|
||||||
// identified. Any remaining should be cleaned up below.
|
// identified. Any remaining should be cleaned up below.
|
||||||
while (!DeadInsts.empty())
|
while (!DeadInsts.empty())
|
||||||
if (Instruction *Inst =
|
if (Instruction *Inst =
|
||||||
dyn_cast_or_null<Instruction>(&*DeadInsts.pop_back_val()))
|
dyn_cast_or_null<Instruction>(&*DeadInsts.pop_back_val()))
|
||||||
RecursivelyDeleteTriviallyDeadInstructions(Inst);
|
RecursivelyDeleteTriviallyDeadInstructions(Inst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point, the code is well formed. We now do a quick sweep over the
|
// At this point, the code is well formed. We now do a quick sweep over the
|
||||||
// inserted code, doing constant propagation and dead code elimination as we
|
// inserted code, doing constant propagation and dead code elimination as we
|
||||||
// go.
|
// go.
|
||||||
|
|
|
@ -237,6 +237,8 @@ bool llvm::UnrollRuntimeLoopProlog(Loop *L, unsigned Count, LoopInfo *LI,
|
||||||
|
|
||||||
// Use Scalar Evolution to compute the trip count. This allows more
|
// Use Scalar Evolution to compute the trip count. This allows more
|
||||||
// loops to be unrolled than relying on induction var simplification
|
// loops to be unrolled than relying on induction var simplification
|
||||||
|
if (!LPM)
|
||||||
|
return false;
|
||||||
ScalarEvolution *SE = LPM->getAnalysisIfAvailable<ScalarEvolution>();
|
ScalarEvolution *SE = LPM->getAnalysisIfAvailable<ScalarEvolution>();
|
||||||
if (SE == 0)
|
if (SE == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue