aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUnroll.cpp
diff options
context:
space:
mode:
authorSam Parker <sam.parker@arm.com>2017-08-14 09:25:26 +0000
committerSam Parker <sam.parker@arm.com>2017-08-14 09:25:26 +0000
commit718c8a6a2a57cfb08c9ef00d50ece1e109b04a49 (patch)
tree84faf30e41926e04f2e9cceb5f32848cff0a3bb0 /llvm/lib/Transforms/Utils/LoopUnroll.cpp
parent647cce82a33c098e549b9addb0bd47928372f318 (diff)
downloadllvm-718c8a6a2a57cfb08c9ef00d50ece1e109b04a49.zip
llvm-718c8a6a2a57cfb08c9ef00d50ece1e109b04a49.tar.gz
llvm-718c8a6a2a57cfb08c9ef00d50ece1e109b04a49.tar.bz2
[LoopUnroll] Enable option to peel remainder loop
On some targets, the penalty of executing runtime unrolling checks and then not the unrolled loop can be significantly detrimental to performance. This results in the need to be more conservative with the unroll count, keeping a trip count of 2 reduces the overhead as well as increasing the chance of the unrolled body being executed. But being conservative leaves performance gains on the table. This patch enables the unrolling of the remainder loop introduced by runtime unrolling. This can help reduce the overhead of misunrolled loops because the cost of non-taken branches is much less than the cost of the backedge that would normally be executed in the remainder loop. This allows larger unroll factors to be used without suffering performance loses with smaller iteration counts. Differential Revision: https://reviews.llvm.org/D36309 llvm-svn: 310824
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnroll.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUnroll.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
index f2527f8..835f439 100644
--- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
@@ -295,7 +295,8 @@ static bool isEpilogProfitable(Loop *L) {
bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount, bool Force,
bool AllowRuntime, bool AllowExpensiveTripCount,
bool PreserveCondBr, bool PreserveOnlyFirst,
- unsigned TripMultiple, unsigned PeelCount, LoopInfo *LI,
+ unsigned TripMultiple, unsigned PeelCount,
+ bool UnrollRemainder, LoopInfo *LI,
ScalarEvolution *SE, DominatorTree *DT,
AssumptionCache *AC, OptimizationRemarkEmitter *ORE,
bool PreserveLCSSA) {
@@ -418,7 +419,8 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount, bool Force,
if (RuntimeTripCount && TripMultiple % Count != 0 &&
!UnrollRuntimeLoopRemainder(L, Count, AllowExpensiveTripCount,
- EpilogProfitability, LI, SE, DT,
+ EpilogProfitability, UnrollRemainder,
+ LI, SE, DT, AC, ORE,
PreserveLCSSA)) {
if (Force)
RuntimeTripCount = false;