[llvm] r361560 - [NewPassManager] Add tuning option: ForgetAllSCEVInLoopUnroll [NFC].
Alina Sbirlea via llvm-commits
llvm-commits at lists.llvm.org
Thu May 23 14:52:59 PDT 2019
Author: asbirlea
Date: Thu May 23 14:52:59 2019
New Revision: 361560
URL: http://llvm.org/viewvc/llvm-project?rev=361560&view=rev
Log:
[NewPassManager] Add tuning option: ForgetAllSCEVInLoopUnroll [NFC].
Summary: Mirror tuning option from old pass manager in new pass manager.
Reviewers: chandlerc
Subscribers: mehdi_amini, jlebar, zzheng, dmgreen, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61612
Modified:
llvm/trunk/include/llvm/Passes/PassBuilder.h
llvm/trunk/include/llvm/Transforms/Scalar/LoopUnrollPass.h
llvm/trunk/lib/Passes/PassBuilder.cpp
llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp
Modified: llvm/trunk/include/llvm/Passes/PassBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Passes/PassBuilder.h?rev=361560&r1=361559&r2=361560&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Passes/PassBuilder.h (original)
+++ llvm/trunk/include/llvm/Passes/PassBuilder.h Thu May 23 14:52:59 2019
@@ -88,6 +88,10 @@ public:
/// Tuning option to enable/disable loop unrolling. Its default value is true.
bool LoopUnrolling;
+ /// Tuning option to forget all SCEV loops in LoopUnroll. Its default value
+ /// is that of the flag: `-forget-scev-loop-unroll`.
+ bool ForgetAllSCEVInLoopUnroll;
+
/// Tuning option to cap the number of calls to retrive clobbering accesses in
/// MemorySSA, in LICM.
unsigned LicmMssaOptCap;
Modified: llvm/trunk/include/llvm/Transforms/Scalar/LoopUnrollPass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar/LoopUnrollPass.h?rev=361560&r1=361559&r2=361560&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Scalar/LoopUnrollPass.h (original)
+++ llvm/trunk/include/llvm/Transforms/Scalar/LoopUnrollPass.h Thu May 23 14:52:59 2019
@@ -15,6 +15,8 @@
namespace llvm {
+extern cl::opt<bool> ForgetSCEVInLoopUnroll;
+
class Function;
class Loop;
class LPMUpdater;
@@ -28,9 +30,16 @@ class LoopFullUnrollPass : public PassIn
/// metadata are considered. All other loops are skipped.
const bool OnlyWhenForced;
+ /// If true, forget all loops when unrolling. If false, forget top-most loop
+ /// of the currently processed loops, which removes one entry at a time from
+ /// the internal SCEV records. For large loops, the former is faster.
+ const bool ForgetSCEV;
+
public:
- explicit LoopFullUnrollPass(int OptLevel = 2, bool OnlyWhenForced = false)
- : OptLevel(OptLevel), OnlyWhenForced(OnlyWhenForced) {}
+ explicit LoopFullUnrollPass(int OptLevel = 2, bool OnlyWhenForced = false,
+ bool ForgetSCEV = false)
+ : OptLevel(OptLevel), OnlyWhenForced(OnlyWhenForced),
+ ForgetSCEV(ForgetSCEV) {}
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR, LPMUpdater &U);
@@ -60,8 +69,15 @@ struct LoopUnrollOptions {
/// metadata are considered. All other loops are skipped.
bool OnlyWhenForced;
- LoopUnrollOptions(int OptLevel = 2, bool OnlyWhenForced = false)
- : OptLevel(OptLevel), OnlyWhenForced(OnlyWhenForced) {}
+ /// If true, forget all loops when unrolling. If false, forget top-most loop
+ /// of the currently processed loops, which removes one entry at a time from
+ /// the internal SCEV records. For large loops, the former is faster.
+ const bool ForgetSCEV;
+
+ LoopUnrollOptions(int OptLevel = 2, bool OnlyWhenForced = false,
+ bool ForgetSCEV = false)
+ : OptLevel(OptLevel), OnlyWhenForced(OnlyWhenForced),
+ ForgetSCEV(ForgetSCEV) {}
/// Enables or disables partial unrolling. When disabled only full unrolling
/// is allowed.
Modified: llvm/trunk/lib/Passes/PassBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Passes/PassBuilder.cpp?rev=361560&r1=361559&r2=361560&view=diff
==============================================================================
--- llvm/trunk/lib/Passes/PassBuilder.cpp (original)
+++ llvm/trunk/lib/Passes/PassBuilder.cpp Thu May 23 14:52:59 2019
@@ -218,6 +218,7 @@ PipelineTuningOptions::PipelineTuningOpt
LoopVectorization = EnableLoopVectorization;
SLPVectorization = RunSLPVectorization;
LoopUnrolling = true;
+ ForgetAllSCEVInLoopUnroll = ForgetSCEVInLoopUnroll;
LicmMssaOptCap = SetLicmMssaOptCap;
LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap;
}
@@ -463,7 +464,8 @@ PassBuilder::buildFunctionSimplification
if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
PGOOpt->Action != PGOOptions::SampleUse) &&
PTO.LoopUnrolling)
- LPM2.addPass(LoopFullUnrollPass(Level));
+ LPM2.addPass(
+ LoopFullUnrollPass(Level, false, PTO.ForgetAllSCEVInLoopUnroll));
for (auto &C : LoopOptimizerEndEPCallbacks)
C(LPM2, Level);
@@ -910,7 +912,8 @@ ModulePassManager PassBuilder::buildModu
createFunctionToLoopPassAdaptor(LoopUnrollAndJamPass(Level)));
}
if (PTO.LoopUnrolling)
- OptimizePM.addPass(LoopUnrollPass(LoopUnrollOptions(Level)));
+ OptimizePM.addPass(LoopUnrollPass(
+ LoopUnrollOptions(Level, false, PTO.ForgetAllSCEVInLoopUnroll)));
OptimizePM.addPass(WarnMissedTransformationsPass());
OptimizePM.addPass(InstCombinePass());
OptimizePM.addPass(RequireAnalysisPass<OptimizationRemarkEmitterAnalysis, Function>());
Modified: llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=361560&r1=361559&r2=361560&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp Thu May 23 14:52:59 2019
@@ -39,6 +39,7 @@
#include "llvm/Transforms/Scalar/GVN.h"
#include "llvm/Transforms/Scalar/InstSimplifyPass.h"
#include "llvm/Transforms/Scalar/LICM.h"
+#include "llvm/Transforms/Scalar/LoopUnrollPass.h"
#include "llvm/Transforms/Scalar/SimpleLoopUnswitch.h"
#include "llvm/Transforms/Utils.h"
#include "llvm/Transforms/Vectorize.h"
@@ -145,12 +146,6 @@ cl::opt<bool> EnableOrderFileInstrumenta
"enable-order-file-instrumentation", cl::init(false), cl::Hidden,
cl::desc("Enable order file instrumentation (default = off)"));
-cl::opt<bool> ForgetSCEVInLoopUnroll(
- "forget-scev-loop-unroll", cl::init(false), cl::Hidden,
- cl::desc("Forget everything in SCEV when doing LoopUnroll, instead of just"
- " the current top-most loop. This is somtimes preferred to reduce"
- " compile time."));
-
PassManagerBuilder::PassManagerBuilder() {
OptLevel = 2;
SizeLevel = 0;
Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp?rev=361560&r1=361559&r2=361560&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp Thu May 23 14:52:59 2019
@@ -71,6 +71,12 @@ using namespace llvm;
#define DEBUG_TYPE "loop-unroll"
+cl::opt<bool> llvm::ForgetSCEVInLoopUnroll(
+ "forget-scev-loop-unroll", cl::init(false), cl::Hidden,
+ cl::desc("Forget everything in SCEV when doing LoopUnroll, instead of just"
+ " the current top-most loop. This is somtimes preferred to reduce"
+ " compile time."));
+
static cl::opt<unsigned>
UnrollThreshold("unroll-threshold", cl::Hidden,
cl::desc("The cost threshold for loop unrolling"));
@@ -1281,7 +1287,7 @@ PreservedAnalyses LoopFullUnrollPass::ru
tryToUnrollLoop(&L, AR.DT, &AR.LI, AR.SE, AR.TTI, AR.AC, *ORE,
/*BFI*/ nullptr, /*PSI*/ nullptr,
/*PreserveLCSSA*/ true, OptLevel, OnlyWhenForced,
- /*ForgetAllSCEV*/ false, /*Count*/ None,
+ ForgetSCEV, /*Count*/ None,
/*Threshold*/ None, /*AllowPartial*/ false,
/*Runtime*/ false, /*UpperBound*/ false,
/*AllowPeeling*/ false) != LoopUnrollResult::Unmodified;
@@ -1422,7 +1428,7 @@ PreservedAnalyses LoopUnrollPass::run(Fu
LoopUnrollResult Result = tryToUnrollLoop(
&L, DT, &LI, SE, TTI, AC, ORE, BFI, PSI,
/*PreserveLCSSA*/ true, UnrollOpts.OptLevel, UnrollOpts.OnlyWhenForced,
- /*ForgetAllSCEV*/ false, /*Count*/ None,
+ UnrollOpts.ForgetSCEV, /*Count*/ None,
/*Threshold*/ None, UnrollOpts.AllowPartial, UnrollOpts.AllowRuntime,
UnrollOpts.AllowUpperBound, LocalAllowPeeling);
Changed |= Result != LoopUnrollResult::Unmodified;
More information about the llvm-commits
mailing list