Skip to content
Snippets Groups Projects
Commit 731b04ca authored by Haicheng Wu's avatar Haicheng Wu
Browse files

[LoopUnroll] Move code to exit early. NFC.

Just to save some compilation time.

Differential Revision: https://reviews.llvm.org/D26784

llvm-svn: 287800
parent 20b6d3d0
No related branches found
No related tags found
No related merge requests found
...@@ -948,7 +948,11 @@ static bool tryToUnrollLoop(Loop *L, DominatorTree &DT, LoopInfo *LI, ...@@ -948,7 +948,11 @@ static bool tryToUnrollLoop(Loop *L, DominatorTree &DT, LoopInfo *LI,
Optional<bool> ProvidedUpperBound) { Optional<bool> ProvidedUpperBound) {
DEBUG(dbgs() << "Loop Unroll: F[" << L->getHeader()->getParent()->getName() DEBUG(dbgs() << "Loop Unroll: F[" << L->getHeader()->getParent()->getName()
<< "] Loop %" << L->getHeader()->getName() << "\n"); << "] Loop %" << L->getHeader()->getName() << "\n");
if (HasUnrollDisablePragma(L)) { if (HasUnrollDisablePragma(L))
return false;
if (!L->isLoopSimplifyForm()) {
DEBUG(
dbgs() << " Not unrolling loop which is not in loop-simplify form.\n");
return false; return false;
} }
...@@ -958,6 +962,9 @@ static bool tryToUnrollLoop(Loop *L, DominatorTree &DT, LoopInfo *LI, ...@@ -958,6 +962,9 @@ static bool tryToUnrollLoop(Loop *L, DominatorTree &DT, LoopInfo *LI,
TargetTransformInfo::UnrollingPreferences UP = gatherUnrollingPreferences( TargetTransformInfo::UnrollingPreferences UP = gatherUnrollingPreferences(
L, TTI, ProvidedThreshold, ProvidedCount, ProvidedAllowPartial, L, TTI, ProvidedThreshold, ProvidedCount, ProvidedAllowPartial,
ProvidedRuntime, ProvidedUpperBound); ProvidedRuntime, ProvidedUpperBound);
// Exit early if unrolling is disabled.
if (UP.Threshold == 0 && (!UP.Partial || UP.PartialThreshold == 0))
return false;
unsigned LoopSize = ApproximateLoopSize( unsigned LoopSize = ApproximateLoopSize(
L, NumInlineCandidates, NotDuplicatable, Convergent, TTI, &AC, UP.BEInsns); L, NumInlineCandidates, NotDuplicatable, Convergent, TTI, &AC, UP.BEInsns);
DEBUG(dbgs() << " Loop Size = " << LoopSize << "\n"); DEBUG(dbgs() << " Loop Size = " << LoopSize << "\n");
...@@ -970,11 +977,6 @@ static bool tryToUnrollLoop(Loop *L, DominatorTree &DT, LoopInfo *LI, ...@@ -970,11 +977,6 @@ static bool tryToUnrollLoop(Loop *L, DominatorTree &DT, LoopInfo *LI,
DEBUG(dbgs() << " Not unrolling loop with inlinable calls.\n"); DEBUG(dbgs() << " Not unrolling loop with inlinable calls.\n");
return false; return false;
} }
if (!L->isLoopSimplifyForm()) {
DEBUG(
dbgs() << " Not unrolling loop which is not in loop-simplify form.\n");
return false;
}
// Find trip count and trip multiple if count is not available // Find trip count and trip multiple if count is not available
unsigned TripCount = 0; unsigned TripCount = 0;
...@@ -991,10 +993,6 @@ static bool tryToUnrollLoop(Loop *L, DominatorTree &DT, LoopInfo *LI, ...@@ -991,10 +993,6 @@ static bool tryToUnrollLoop(Loop *L, DominatorTree &DT, LoopInfo *LI,
TripMultiple = SE->getSmallConstantTripMultiple(L, ExitingBlock); TripMultiple = SE->getSmallConstantTripMultiple(L, ExitingBlock);
} }
// Exit early if unrolling is disabled.
if (UP.Threshold == 0 && (!UP.Partial || UP.PartialThreshold == 0))
return false;
// If the loop contains a convergent operation, the prelude we'd add // If the loop contains a convergent operation, the prelude we'd add
// to do the first few instructions before we hit the unrolled loop // to do the first few instructions before we hit the unrolled loop
// is unsafe -- it adds a control-flow dependency to the convergent // is unsafe -- it adds a control-flow dependency to the convergent
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment