Skip to content

Commit

Permalink
[NewPassManager] Add tuning option: LoopUnrolling [NFC].
Browse files Browse the repository at this point in the history
Summary: Mirror tuning option from old pass manager in new pass manager.

Reviewers: chandlerc

Subscribers: jlebar, dmgreen, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D61618

llvm-svn: 361540
  • Loading branch information
alinas committed May 23, 2019
1 parent a83bf47 commit e4b2786
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions llvm/include/llvm/Passes/PassBuilder.h
Expand Up @@ -85,6 +85,9 @@ class PipelineTuningOptions {
/// is that of the flag: `vectorize-slp`.
bool SLPVectorization;

/// Tuning option to enable/disable loop unrolling. Its default value is true.
bool LoopUnrolling;

/// Tuning option to cap the number of calls to retrive clobbering accesses in
/// MemorySSA, in LICM.
unsigned LicmMssaOptCap;
Expand Down
9 changes: 6 additions & 3 deletions llvm/lib/Passes/PassBuilder.cpp
Expand Up @@ -217,6 +217,7 @@ PipelineTuningOptions::PipelineTuningOptions() {
LoopInterleaving = EnableLoopInterleaving;
LoopVectorization = EnableLoopVectorization;
SLPVectorization = RunSLPVectorization;
LoopUnrolling = true;
LicmMssaOptCap = SetLicmMssaOptCap;
LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap;
}
Expand Down Expand Up @@ -459,8 +460,9 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
// Do not enable unrolling in PreLinkThinLTO phase during sample PGO
// because it changes IR to makes profile annotation in back compile
// inaccurate.
if (Phase != ThinLTOPhase::PreLink || !PGOOpt ||
PGOOpt->Action != PGOOptions::SampleUse)
if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
PGOOpt->Action != PGOOptions::SampleUse) &&
PTO.LoopUnrolling)
LPM2.addPass(LoopFullUnrollPass(Level));

for (auto &C : LoopOptimizerEndEPCallbacks)
Expand Down Expand Up @@ -907,7 +909,8 @@ ModulePassManager PassBuilder::buildModuleOptimizationPipeline(
OptimizePM.addPass(
createFunctionToLoopPassAdaptor(LoopUnrollAndJamPass(Level)));
}
OptimizePM.addPass(LoopUnrollPass(LoopUnrollOptions(Level)));
if (PTO.LoopUnrolling)
OptimizePM.addPass(LoopUnrollPass(LoopUnrollOptions(Level)));
OptimizePM.addPass(WarnMissedTransformationsPass());
OptimizePM.addPass(InstCombinePass());
OptimizePM.addPass(RequireAnalysisPass<OptimizationRemarkEmitterAnalysis, Function>());
Expand Down

0 comments on commit e4b2786

Please sign in to comment.