[PATCH] D64972: [Loop Peeling] Do not close further unroll/peel if profile based peeling was not used
Serguei Katkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 02:03:49 PDT 2019
skatkov updated this revision to Diff 211029.
skatkov retitled this revision from "[Loop Peeling] Do not close further unroll/peel if not full peeling happens" to "[Loop Peeling] Do not close further unroll/peel if profile based peeling was not used".
skatkov added a comment.
Test is updated to show what this patch changes.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64972/new/
https://reviews.llvm.org/D64972
Files:
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll
Index: llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll
===================================================================
--- llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll
+++ llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll
@@ -643,3 +643,4 @@
for.end:
ret void
}
+; CHECK-NOT: llvm.loop.unroll.disable
\ No newline at end of file
Index: llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
+++ llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
@@ -275,6 +275,7 @@
LLVM_DEBUG(dbgs() << "Force-peeling first " << UnrollForcePeelCount
<< " iterations.\n");
UP.PeelCount = UnrollForcePeelCount;
+ UP.PeelProfiledIterations = true;
return;
}
@@ -321,6 +322,7 @@
<< " iteration(s) to turn"
<< " some Phis into invariants.\n");
UP.PeelCount = DesiredPeelCount;
+ UP.PeelProfiledIterations = false;
return;
}
}
@@ -330,6 +332,9 @@
if (TripCount)
return;
+ // Do not apply profile base peeling if it is disabled.
+ if (!UP.PeelProfiledIterations)
+ 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.
Index: llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -202,6 +202,7 @@
UP.UpperBound = false;
UP.AllowPeeling = true;
UP.UnrollAndJam = false;
+ UP.PeelProfiledIterations = true;
UP.UnrollAndJamInnerLoopThreshold = 60;
// Override with any target specific settings
@@ -1139,7 +1140,7 @@
// If the loop was peeled, we already "used up" the profile information
// we had, so we don't want to unroll or peel again.
if (UnrollResult != LoopUnrollResult::FullyUnrolled &&
- (IsCountSetExplicitly || UP.PeelCount))
+ (IsCountSetExplicitly || (UP.PeelProfiledIterations && UP.PeelCount)))
L->setLoopAlreadyUnrolled();
return UnrollResult;
Index: llvm/include/llvm/Analysis/TargetTransformInfo.h
===================================================================
--- llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -475,6 +475,11 @@
bool UnrollRemainder;
/// Allow unroll and jam. Used to enable unroll and jam for the target.
bool UnrollAndJam;
+ /// Allow peeling basing on profile. Uses to enable peeling off all
+ /// iterations basing on provided profile.
+ /// If the value is true the peeling cost model can decide to peel only
+ /// some iteration and in this case it will set this to false.
+ bool PeelProfiledIterations;
/// Threshold for unroll and jam, for inner loop size. The 'Threshold'
/// value above is used during unroll and jam for the outer loop size.
/// This value is used in the same manner to limit the size of the inner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64972.211029.patch
Type: text/x-patch
Size: 3166 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190722/f338f117/attachment.bin>
More information about the llvm-commits
mailing list