From: Alina Sbirlea Date: Thu, 23 May 2019 19:35:40 +0000 (+0000) Subject: [NewPassManager] Add tuning option: LoopUnrolling [NFC]. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=89828fde7f568cffc6f5b08f831cf7a0e2e38034;p=llvm [NewPassManager] Add tuning option: LoopUnrolling [NFC]. 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361540 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Passes/PassBuilder.h b/include/llvm/Passes/PassBuilder.h index 69756dd9b46..383f49e0d75 100644 --- a/include/llvm/Passes/PassBuilder.h +++ b/include/llvm/Passes/PassBuilder.h @@ -85,6 +85,9 @@ public: /// 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; diff --git a/lib/Passes/PassBuilder.cpp b/lib/Passes/PassBuilder.cpp index c7976ce2702..1d17f91d5a8 100644 --- a/lib/Passes/PassBuilder.cpp +++ b/lib/Passes/PassBuilder.cpp @@ -217,6 +217,7 @@ PipelineTuningOptions::PipelineTuningOptions() { LoopInterleaving = EnableLoopInterleaving; LoopVectorization = EnableLoopVectorization; SLPVectorization = RunSLPVectorization; + LoopUnrolling = true; LicmMssaOptCap = SetLicmMssaOptCap; LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap; } @@ -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) @@ -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());