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 @@ -834,7 +834,7 @@ FunctionPassManager FPM; FPM.addPass(createFunctionToLoopPassAdaptor( - LoopRotatePass(), EnableMSSALoopDependency, + LoopRotatePass(Level != OptimizationLevel::Oz), EnableMSSALoopDependency, /*UseBlockFrequencyInfo=*/false, DebugLogging)); MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM))); @@ -1165,7 +1165,7 @@ // First rotate loops that may have been un-rotated by prior passes. OptimizePM.addPass(createFunctionToLoopPassAdaptor( - LoopRotatePass(), EnableMSSALoopDependency, + LoopRotatePass(Level != OptimizationLevel::Oz), EnableMSSALoopDependency, /*UseBlockFrequencyInfo=*/false, DebugLogging)); // Distribute loops to allow partial vectorization. I.e. isolate dependences diff --git a/llvm/test/Transforms/LoopRotate/oz-disable.ll b/llvm/test/Transforms/LoopRotate/oz-disable.ll --- a/llvm/test/Transforms/LoopRotate/oz-disable.ll +++ b/llvm/test/Transforms/LoopRotate/oz-disable.ll @@ -1,6 +1,8 @@ ; REQUIRES: asserts ; RUN: opt < %s -S -Os -debug -debug-only=loop-rotate 2>&1 | FileCheck %s -check-prefix=OS ; RUN: opt < %s -S -Oz -debug -debug-only=loop-rotate 2>&1 | FileCheck %s -check-prefix=OZ +; RUN: opt < %s -S -passes='default' -debug -debug-only=loop-rotate 2>&1 | FileCheck %s -check-prefix=OS +; RUN: opt < %s -S -passes='default' -debug -debug-only=loop-rotate 2>&1 | FileCheck %s -check-prefix=OZ ; Loop should be rotated for -Os but not for -Oz. ; OS: rotating Loop at depth 1