1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

[LoopUnroll] Make LoopPeeling respect the AllowPeeling preference.

The SimpleLoopUnrollPass isn't suppose to perform loop peeling.

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

llvm-svn: 329395
This commit is contained in:
Chad Rosier 2018-04-06 13:57:21 +00:00
parent 11b24c502b
commit 50b613bff2
2 changed files with 17 additions and 10 deletions

View File

@ -232,6 +232,19 @@ void llvm::computePeelCount(Loop *L, unsigned LoopSize,
if (!L->empty())
return;
// If the user provided a peel count, use that.
bool UserPeelCount = UnrollForcePeelCount.getNumOccurrences() > 0;
if (UserPeelCount) {
DEBUG(dbgs() << "Force-peeling first " << UnrollForcePeelCount
<< " iterations.\n");
UP.PeelCount = UnrollForcePeelCount;
return;
}
// Skip peeling if it's disabled.
if (!UP.AllowPeeling)
return;
// Here we try to get rid of Phis which become invariants after 1, 2, ..., N
// iterations of the loop. For this we compute the number for iterations after
// which every Phi is guaranteed to become an invariant, and try to peel the
@ -279,21 +292,12 @@ void llvm::computePeelCount(Loop *L, unsigned LoopSize,
if (TripCount)
return;
// If the user provided a peel count, use that.
bool UserPeelCount = UnrollForcePeelCount.getNumOccurrences() > 0;
if (UserPeelCount) {
DEBUG(dbgs() << "Force-peeling first " << UnrollForcePeelCount
<< " iterations.\n");
UP.PeelCount = UnrollForcePeelCount;
return;
}
// If we don't know the trip count, but have reason to believe the average
// trip count is low, peeling should be beneficial, since we will usually
// hit the peeled section.
// We only do this in the presence of profile information, since otherwise
// our estimates of the trip count are not reliable enough.
if (UP.AllowPeeling && L->getHeader()->getParent()->hasProfileData()) {
if (L->getHeader()->getParent()->hasProfileData()) {
Optional<unsigned> PeelCount = getLoopEstimatedTripCount(L);
if (!PeelCount)
return;

View File

@ -1,4 +1,5 @@
; RUN: opt < %s -S -loop-unroll -unroll-threshold=30 | FileCheck %s
; RUN: opt < %s -S -loop-unroll -unroll-threshold=30 -unroll-allow-peeling=false | FileCheck %s --check-prefix=DISABLE
define i32 @invariant_backedge_1(i32 %a, i32 %b) {
; CHECK-LABEL: @invariant_backedge_1
@ -7,6 +8,8 @@ define i32 @invariant_backedge_1(i32 %a, i32 %b) {
; CHECK: loop:
; CHECK: %i = phi
; CHECK: %sum = phi
; DISABLE-LABEL: @invariant_backedge_1
; DISABLE-NOT: loop.peel:
entry:
br label %loop