[llvm] r329395 - [LoopUnroll] Make LoopPeeling respect the AllowPeeling preference.
Chad Rosier via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 6 06:57:21 PDT 2018
Author: mcrosier
Date: Fri Apr 6 06:57:21 2018
New Revision: 329395
URL: http://llvm.org/viewvc/llvm-project?rev=329395&view=rev
Log:
[LoopUnroll] Make LoopPeeling respect the AllowPeeling preference.
The SimpleLoopUnrollPass isn't suppose to perform loop peeling.
Differential Revision: https://reviews.llvm.org/D45334
Modified:
llvm/trunk/lib/Transforms/Utils/LoopUnrollPeel.cpp
llvm/trunk/test/Transforms/LoopUnroll/peel-loop-not-forced.ll
Modified: llvm/trunk/lib/Transforms/Utils/LoopUnrollPeel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopUnrollPeel.cpp?rev=329395&r1=329394&r2=329395&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopUnrollPeel.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopUnrollPeel.cpp Fri Apr 6 06:57:21 2018
@@ -232,6 +232,19 @@ void llvm::computePeelCount(Loop *L, uns
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, uns
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;
Modified: llvm/trunk/test/Transforms/LoopUnroll/peel-loop-not-forced.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnroll/peel-loop-not-forced.ll?rev=329395&r1=329394&r2=329395&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopUnroll/peel-loop-not-forced.ll (original)
+++ llvm/trunk/test/Transforms/LoopUnroll/peel-loop-not-forced.ll Fri Apr 6 06:57:21 2018
@@ -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,
; CHECK: loop:
; CHECK: %i = phi
; CHECK: %sum = phi
+; DISABLE-LABEL: @invariant_backedge_1
+; DISABLE-NOT: loop.peel:
entry:
br label %loop
More information about the llvm-commits
mailing list