[PATCH] D88471: [Passes] Run peeling as part of simple/full loop unrolling.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 04:30:42 PDT 2020
fhahn updated this revision to Diff 295788.
fhahn added a comment.
In D88471#2308260 <https://reviews.llvm.org/D88471#2308260>, @lebedev.ri wrote:
> The patch doesn't seem to apply for me:
Rebased, should apply now.
In terms of runtime impact, I measured the following impact on SPEC2006 on ARM64 with -O3 -flto, outside the noise:
test-suite...006/450.soplex/450.soplex.test -2.4%
test-suite...6/464.h264ref/464.h264ref.test 1.3%
test-suite...T2006/473.astar/473.astar.test -0.9%
Presumably the h264ref regression is related to wrong decisions in the cost modeling and probably warrants some further analysis.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88471/new/
https://reviews.llvm.org/D88471
Files:
llvm/include/llvm/Transforms/Scalar.h
llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
llvm/test/Transforms/PhaseOrdering/X86/peel-before-lv-to-enable-vectorization.ll
Index: llvm/test/Transforms/PhaseOrdering/X86/peel-before-lv-to-enable-vectorization.ll
===================================================================
--- llvm/test/Transforms/PhaseOrdering/X86/peel-before-lv-to-enable-vectorization.ll
+++ llvm/test/Transforms/PhaseOrdering/X86/peel-before-lv-to-enable-vectorization.ll
@@ -11,7 +11,9 @@
define i32 @test(i32* readonly %p, i32* readnone %q) {
; CHECK-LABEL: define i32 @test(
-; CHECK-NOT: vector.body
+; CHECK: vector.body:
+; CHECK: %index.next = add i64 %index, 8
+; CHECK: middle.block:
;
entry:
%cmp.not7 = icmp eq i32* %p, %q
Index: llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -1299,7 +1299,7 @@
Pass *llvm::createSimpleLoopUnrollPass(int OptLevel, bool OnlyWhenForced,
bool ForgetAllSCEV) {
return createLoopUnrollPass(OptLevel, OnlyWhenForced, ForgetAllSCEV, -1, -1,
- 0, 0, 0, 0);
+ 0, 0, 0, 1);
}
PreservedAnalyses LoopFullUnrollPass::run(Loop &L, LoopAnalysisManager &AM,
@@ -1327,7 +1327,7 @@
OnlyWhenForced, ForgetSCEV, /*Count*/ None,
/*Threshold*/ None, /*AllowPartial*/ false,
/*Runtime*/ false, /*UpperBound*/ false,
- /*AllowPeeling*/ false,
+ /*AllowPeeling*/ true,
/*AllowProfileBasedPeeling*/ false,
/*FullUnrollMaxCount*/ None) !=
LoopUnrollResult::Unmodified;
Index: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
===================================================================
--- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -453,7 +453,7 @@
MPM.add(createLoopSimplifyCFGPass());
}
- // Unroll small loops
+ // Unroll small loops and perform peeling.
MPM.add(createSimpleLoopUnrollPass(OptLevel, DisableUnrollLoops,
ForgetAllSCEVInLoopUnroll));
addExtensionsToPM(EP_LoopOptimizerEnd, MPM);
@@ -1046,7 +1046,7 @@
if (EnableLoopFlatten)
PM.add(createLoopFlattenPass());
- // Unroll small loops
+ // Unroll small loops and perform peeling.
PM.add(createSimpleLoopUnrollPass(OptLevel, DisableUnrollLoops,
ForgetAllSCEVInLoopUnroll));
PM.add(createLoopVectorizePass(true, !LoopVectorize));
Index: llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h
===================================================================
--- llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h
+++ llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h
@@ -22,7 +22,7 @@
class Loop;
class LPMUpdater;
-/// Loop unroll pass that only does full loop unrolling.
+/// Loop unroll pass that only does full loop unrolling and peeling.
class LoopFullUnrollPass : public PassInfoMixin<LoopFullUnrollPass> {
const int OptLevel;
Index: llvm/include/llvm/Transforms/Scalar.h
===================================================================
--- llvm/include/llvm/Transforms/Scalar.h
+++ llvm/include/llvm/Transforms/Scalar.h
@@ -184,7 +184,8 @@
int Count = -1, int AllowPartial = -1,
int Runtime = -1, int UpperBound = -1,
int AllowPeeling = -1);
-// Create an unrolling pass for full unrolling that uses exact trip count only.
+// Create an unrolling pass for full unrolling that uses exact trip count only
+// and also does peeling.
Pass *createSimpleLoopUnrollPass(int OptLevel = 2, bool OnlyWhenForced = false,
bool ForgetAllSCEV = false);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88471.295788.patch
Type: text/x-patch
Size: 3934 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201002/d013875e/attachment.bin>
More information about the llvm-commits
mailing list