diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/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(true)); LPM2.addPass(LoopIdiomRecognizePass()); LPM2.addPass(IndVarSimplifyPass()); diff --git a/llvm/test/Transforms/LoopUnroll/opt-levels.ll b/llvm/test/Transforms/LoopUnroll/opt-levels.ll --- a/llvm/test/Transforms/LoopUnroll/opt-levels.ll +++ b/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: diff --git a/llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll b/llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll @@ -0,0 +1,39 @@ +; RUN: opt < %s -S -passes="default" | FileCheck %s -check-prefix=O1 +; RUN: opt < %s -S -passes="default" | 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 +}