[PATCH] D30243: [LoopUnrolling] Re-prioritize Peeling and Partial unrolling
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 27 01:45:29 PST 2017
mkazantsev updated this revision to Diff 89848.
mkazantsev edited the summary of this revision.
https://reviews.llvm.org/D30243
Files:
include/llvm/Transforms/Utils/UnrollLoop.h
lib/Transforms/Scalar/LoopUnrollPass.cpp
lib/Transforms/Utils/LoopUnrollPeel.cpp
Index: lib/Transforms/Utils/LoopUnrollPeel.cpp
===================================================================
--- lib/Transforms/Utils/LoopUnrollPeel.cpp
+++ lib/Transforms/Utils/LoopUnrollPeel.cpp
@@ -61,7 +61,8 @@
// Return the number of iterations we want to peel off.
void llvm::computePeelCount(Loop *L, unsigned LoopSize,
- TargetTransformInfo::UnrollingPreferences &UP) {
+ TargetTransformInfo::UnrollingPreferences &UP,
+ bool BaseOnTripCount) {
UP.PeelCount = 0;
if (!canPeel(L))
return;
@@ -84,7 +85,8 @@
// 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()->getEntryCount()) {
+ if (BaseOnTripCount && UP.AllowPeeling &&
+ L->getHeader()->getParent()->getEntryCount()) {
Optional<unsigned> PeelCount = getLoopEstimatedTripCount(L);
if (!PeelCount)
return;
Index: lib/Transforms/Scalar/LoopUnrollPass.cpp
===================================================================
--- lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -784,7 +784,15 @@
}
}
- // 4rd priority is partial unrolling.
+ // 4th priority is loop peeling not basing on trip count.
+ computePeelCount(L, LoopSize, UP, /* BaseOnTripCount */ false);
+ if (UP.PeelCount) {
+ UP.Runtime = false;
+ UP.Count = 1;
+ return ExplicitUnroll;
+ }
+
+ // 5th priority is partial unrolling.
// Try partial unroll only when TripCount could be staticaly calculated.
if (TripCount) {
UP.Partial |= ExplicitUnroll;
@@ -847,15 +855,15 @@
<< "Unable to fully unroll loop as directed by unroll(full) pragma "
"because loop has a runtime trip count.");
- // 5th priority is loop peeling
- computePeelCount(L, LoopSize, UP);
+ // 6th priority is loop peeling basing on trip count.
+ computePeelCount(L, LoopSize, UP, /* BaseOnTripCount */ true);
if (UP.PeelCount) {
UP.Runtime = false;
UP.Count = 1;
return ExplicitUnroll;
}
- // 6th priority is runtime unrolling.
+ // 7th priority is runtime unrolling.
// Don't unroll a runtime trip count loop when it is disabled.
if (HasRuntimeUnrollDisablePragma(L)) {
UP.Count = 0;
Index: include/llvm/Transforms/Utils/UnrollLoop.h
===================================================================
--- include/llvm/Transforms/Utils/UnrollLoop.h
+++ include/llvm/Transforms/Utils/UnrollLoop.h
@@ -53,7 +53,8 @@
bool PreserveLCSSA);
void computePeelCount(Loop *L, unsigned LoopSize,
- TargetTransformInfo::UnrollingPreferences &UP);
+ TargetTransformInfo::UnrollingPreferences &UP,
+ bool BaseOnTripCount);
bool peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI, ScalarEvolution *SE,
DominatorTree *DT, AssumptionCache *AC, bool PreserveLCSSA);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30243.89848.patch
Type: text/x-patch
Size: 3093 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170227/ab6a6807/attachment.bin>
More information about the llvm-commits
mailing list