bool SamplePGOSupport;
};
+/// Tunable parameters for passes in the default pipelines.
+class PipelineTuningOptions {
+public:
+ /// Constructor sets pipeline tuning defaults based on cl::opts. Each option
+ /// can be set in the PassBuilder when using a LLVM as a library.
+ PipelineTuningOptions();
+
+ /// Tuning option to set loop interleaving on/off. Its default value is that
+ /// of the flag: `-interleave-loops`.
+ bool LoopInterleaving;
+
+ /// Tuning option to enable/disable loop vectorization. Its default value is
+ /// that of the flag: `-vectorize-loops`.
+ bool LoopVectorization;
+};
+
/// This class provides access to building LLVM's passes.
///
/// Its members provide the baseline state available to passes during their
/// construction.
class PassBuilder {
TargetMachine *TM;
+ PipelineTuningOptions PTO;
Optional<PGOOptions> PGOOpt;
PassInstrumentationCallbacks *PIC;
};
explicit PassBuilder(TargetMachine *TM = nullptr,
+ PipelineTuningOptions PTO = PipelineTuningOptions(),
Optional<PGOOptions> PGOOpt = None,
PassInstrumentationCallbacks *PIC = nullptr)
- : TM(TM), PGOOpt(PGOOpt), PIC(PIC) {}
+ : TM(TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC) {}
/// Cross register the analysis managers through their proxies.
///
//
// LoopVectorize - Create a loop vectorization pass.
//
-Pass *createLoopVectorizePass(bool InterleaveOnlyWhenForced = false,
- bool VectorizeOnlyWhenForced = false);
+Pass *createLoopVectorizePass();
+Pass *createLoopVectorizePass(bool InterleaveOnlyWhenForced,
+ bool VectorizeOnlyWhenForced);
//===----------------------------------------------------------------------===//
//
class TargetLibraryInfo;
class TargetTransformInfo;
+extern cl::opt<bool> EnableLoopInterleaving;
+extern cl::opt<bool> EnableLoopVectorization;
+
struct LoopVectorizeOptions {
/// If false, consider all loops for interleaving.
/// If true, only loops that explicitly request interleaving are considered.
/// If true, only loops that explicitly request vectorization are considered.
bool VectorizeOnlyWhenForced;
+ /// The current defaults when creating the pass with no arguments are:
+ /// EnableLoopInterleaving = true and EnableLoopVectorization = true. This
+ /// means that interleaving default is consistent with the cl::opt flag, while
+ /// vectorization is not.
+ /// FIXME: The default for EnableLoopVectorization in the cl::opt should be
+ /// set to true, and the corresponding change to account for this be made in
+ /// opt.cpp. The initializations below will become:
+ /// InterleaveOnlyWhenForced(!EnableLoopInterleaving)
+ /// VectorizeOnlyWhenForced(!EnableLoopVectorization).
LoopVectorizeOptions()
: InterleaveOnlyWhenForced(false), VectorizeOnlyWhenForced(false) {}
+ LoopVectorizeOptions(bool InterleaveOnlyWhenForced,
+ bool VectorizeOnlyWhenForced)
+ : InterleaveOnlyWhenForced(InterleaveOnlyWhenForced),
+ VectorizeOnlyWhenForced(VectorizeOnlyWhenForced) {}
LoopVectorizeOptions &setInterleaveOnlyWhenForced(bool Value) {
InterleaveOnlyWhenForced = Value;
PGOOptions::IRUse, PGOOptions::CSIRUse);
}
- PassBuilder PB(TM, PGOOpt);
+ PassBuilder PB(TM, PipelineTuningOptions(), PGOOpt);
AAManager AA;
// Parse a custom AA pipeline if asked to.
EnableCHR("enable-chr-npm", cl::init(true), cl::Hidden,
cl::desc("Enable control height reduction optimization (CHR)"));
+PipelineTuningOptions::PipelineTuningOptions() {
+ LoopInterleaving = EnableLoopInterleaving;
+ LoopVectorization = EnableLoopVectorization;
+}
+
extern cl::opt<bool> EnableHotColdSplit;
extern cl::opt<bool> EnableOrderFileInstrumentation;
OptimizePM.addPass(LoopDistributePass());
// Now run the core loop vectorizer.
- OptimizePM.addPass(LoopVectorizePass());
+ OptimizePM.addPass(LoopVectorizePass(
+ LoopVectorizeOptions(!PTO.LoopInterleaving, !PTO.LoopVectorization)));
// Eliminate loads by forwarding stores from the previous iteration to loads
// of the current iteration.
#include "llvm/Transforms/Scalar/SimpleLoopUnswitch.h"
#include "llvm/Transforms/Utils.h"
#include "llvm/Transforms/Vectorize.h"
+#include "llvm/Transforms/Vectorize/LoopVectorize.h"
using namespace llvm;
cl::ZeroOrMore, cl::desc("Run Partial inlinining pass"));
static cl::opt<bool>
- RunLoopVectorization("vectorize-loops", cl::Hidden,
- cl::desc("Run the Loop vectorization passes"));
-
-static cl::opt<bool>
RunSLPVectorization("vectorize-slp", cl::Hidden,
cl::desc("Run the SLP vectorization passes"));
Inliner = nullptr;
DisableUnrollLoops = false;
SLPVectorize = RunSLPVectorization;
- LoopVectorize = RunLoopVectorization;
+ LoopVectorize = EnableLoopVectorization;
+ // FIXME: Add: LoopsInterleaved = EnableLoopInterleaving;
+ // Replace usage of DisableUnrollLoops with LoopsInterleaved when creating
+ // the LoopVectorize pass, to be consistent with the new pass manager.
RerollLoops = RunLoopRerolling;
NewGVN = RunNewGVN;
DisableGVNLoadPRE = false;
"out right after the build (stress test the VPlan H-CFG construction "
"in the VPlan-native vectorization path)."));
+cl::opt<bool> llvm::EnableLoopInterleaving(
+ "interleave-loops", cl::init(true), cl::Hidden,
+ cl::desc("Enable loop interleaving in Loop vectorization passes"));
+cl::opt<bool> llvm::EnableLoopVectorization(
+ "vectorize-loops", cl::init(false), cl::Hidden,
+ cl::desc("Run the Loop vectorization passes"));
+
/// A helper function for converting Scalar types to vector types.
/// If the incoming type is void, we return void. If the VF is 1, we return
/// the scalar type.
namespace llvm {
+Pass *createLoopVectorizePass() { return new LoopVectorize(); }
+
Pass *createLoopVectorizePass(bool InterleaveOnlyWhenForced,
bool VectorizeOnlyWhenForced) {
return new LoopVectorize(InterleaveOnlyWhenForced, VectorizeOnlyWhenForced);
StandardInstrumentations SI;
SI.registerCallbacks(PIC);
- PassBuilder PB(TM, P, &PIC);
+ PassBuilder PB(TM, PipelineTuningOptions(), P, &PIC);
registerEPCallbacks(PB, VerifyEachPass, DebugPM);
// Load requested pass plugins and let them register pass builder callbacks
"exit:\n"
" ret void\n"
"}\n")),
- CallbacksHandle(), PB(nullptr, None, &CallbacksHandle.Callbacks),
+ CallbacksHandle(),
+ PB(nullptr, PipelineTuningOptions(), None, &CallbacksHandle.Callbacks),
PM(true), LAM(true), FAM(true), CGAM(true), AM(true) {
/// Register a callback for analysis registration.