[PATCH] D94448: [NewPM] Run non-trivial loop unswitching under -O2/3/s/z
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 12 11:05:08 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf748e9229551: [NewPM] Run non-trivial loop unswitching under -O2/3/s/z (authored by aeubanks).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94448/new/
https://reviews.llvm.org/D94448
Files:
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Transforms/LoopUnroll/opt-levels.ll
llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll
Index: llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll
@@ -0,0 +1,39 @@
+; RUN: opt < %s -S -passes="default<O1>" | FileCheck %s -check-prefix=O1
+; RUN: opt < %s -S -passes="default<O2>" | FileCheck %s -check-prefix=O2
+
+declare i32 @a()
+declare i32 @b()
+declare i32 @c()
+
+; O1-NOT: loop_begin.us:
+; O2: loop_begin.us:
+
+define i32 @test1(i1* %ptr, i1 %cond1, i1 %cond2) {
+entry:
+ br label %loop_begin
+
+loop_begin:
+ br i1 %cond1, label %loop_a, label %loop_b
+
+loop_a:
+ call i32 @a()
+ br label %latch
+
+loop_b:
+ br i1 %cond2, label %loop_b_a, label %loop_b_b
+
+loop_b_a:
+ call i32 @b()
+ br label %latch
+
+loop_b_b:
+ call i32 @c()
+ br label %latch
+
+latch:
+ %v = load i1, i1* %ptr
+ br i1 %v, label %loop_begin, label %loop_exit
+
+loop_exit:
+ ret i32 0
+}
Index: llvm/test/Transforms/LoopUnroll/opt-levels.ll
===================================================================
--- llvm/test/Transforms/LoopUnroll/opt-levels.ll
+++ llvm/test/Transforms/LoopUnroll/opt-levels.ll
@@ -7,10 +7,10 @@
; the behavior, we artificially disable unrolling for anything but O3 by setting
; the default threshold to 0.
-; O3: loop2.preheader
-; O2-NOT: loop2.preheader
-; Os-NOT: loop2.preheader
-; Oz-NOT: loop2.preheader
+; O3: loop1.preheader
+; O2-NOT: loop1.preheader
+; Os-NOT: loop1.preheader
+; Oz-NOT: loop1.preheader
define void @unroll(i32 %iter, i32* %addr1, i32* %addr2) nounwind {
entry:
Index: llvm/lib/Passes/PassBuilder.cpp
===================================================================
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -724,7 +724,7 @@
LPM1.addPass(LoopRotatePass(Level != OptimizationLevel::Oz));
// TODO: Investigate promotion cap for O1.
LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap));
- LPM1.addPass(SimpleLoopUnswitchPass());
+ LPM1.addPass(SimpleLoopUnswitchPass(/* NonTrivial */ true));
LPM2.addPass(LoopIdiomRecognizePass());
LPM2.addPass(IndVarSimplifyPass());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94448.316168.patch
Type: text/x-patch
Size: 2168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210112/311dc62f/attachment.bin>
More information about the llvm-commits
mailing list