mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-03 16:03:21 +00:00
In the new pass manager use PTO.LoopUnrolling to determine when and how
we will unroll loops. Also comment a few occasions where we need to know whether or not we're forcing the unwinder or not. The default before and after this patch is for LoopUnroll to be enabled, and for it to use a cost model to determine whether to unroll the loop (`OnlyWhenForced = false`). Before this patch, disabling loop unroll would not run the LoopUnroll pass. After this patch, the LoopUnroll pass is being run, but it restricts unrolling to only the loops marked by a pragma (`OnlyWhenForced = true`). In addition, this patch disables the UnrollAndJam pass when disabling unrolling. Testcase is in clang because it's controlling how the loop optimizer is being set up and there's no other way to trigger the behavior. llvm-svn: 374838
This commit is contained in:
parent
72593d3bdc
commit
c3649a0871
12
clang/test/Misc/loop-opt-setup.c
Normal file
12
clang/test/Misc/loop-opt-setup.c
Normal file
@ -0,0 +1,12 @@
|
||||
// RUN: %clang -O1 -fexperimental-new-pass-manager -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s
|
||||
// RUN: %clang -O1 -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s
|
||||
extern int a[16];
|
||||
int b = 0;
|
||||
int foo(void) {
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 16; ++i)
|
||||
a[i] = b += 2;
|
||||
return b;
|
||||
}
|
||||
// CHECK-NOT: br i1
|
||||
|
@ -471,8 +471,8 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
|
||||
if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
|
||||
PGOOpt->Action != PGOOptions::SampleUse) &&
|
||||
PTO.LoopUnrolling)
|
||||
LPM2.addPass(
|
||||
LoopFullUnrollPass(Level, false, PTO.ForgetAllSCEVInLoopUnroll));
|
||||
LPM2.addPass(LoopFullUnrollPass(Level, /*OnlyWhenForced=*/false,
|
||||
PTO.ForgetAllSCEVInLoopUnroll));
|
||||
|
||||
for (auto &C : LoopOptimizerEndEPCallbacks)
|
||||
C(LPM2, Level);
|
||||
@ -953,13 +953,13 @@ ModulePassManager PassBuilder::buildModuleOptimizationPipeline(
|
||||
// combiner for cleanup here so that the unrolling and LICM can be pipelined
|
||||
// across the loop nests.
|
||||
// We do UnrollAndJam in a separate LPM to ensure it happens before unroll
|
||||
if (EnableUnrollAndJam) {
|
||||
if (EnableUnrollAndJam && PTO.LoopUnrolling) {
|
||||
OptimizePM.addPass(
|
||||
createFunctionToLoopPassAdaptor(LoopUnrollAndJamPass(Level)));
|
||||
}
|
||||
if (PTO.LoopUnrolling)
|
||||
OptimizePM.addPass(LoopUnrollPass(
|
||||
LoopUnrollOptions(Level, false, PTO.ForgetAllSCEVInLoopUnroll)));
|
||||
OptimizePM.addPass(LoopUnrollPass(
|
||||
LoopUnrollOptions(Level, /*OnlyWhenForced=*/!PTO.LoopUnrolling,
|
||||
PTO.ForgetAllSCEVInLoopUnroll)));
|
||||
OptimizePM.addPass(WarnMissedTransformationsPass());
|
||||
OptimizePM.addPass(InstCombinePass());
|
||||
OptimizePM.addPass(RequireAnalysisPass<OptimizationRemarkEmitterAnalysis, Function>());
|
||||
|
Loading…
x
Reference in New Issue
Block a user