31#define DEBUG_TYPE "loop-rotate"
35 cl::desc(
"The default maximum header size for automatic loop rotation"));
39 cl::desc(
"Run loop-rotation in the prepare-for-lto stage. This option "
40 "should be used for testing only."));
43 : EnableHeaderDuplication(EnableHeaderDuplication),
44 PrepareForLTO(PrepareForLTO) {}
49 OS, MapClassName2PassName);
51 if (!EnableHeaderDuplication)
53 OS <<
"header-duplication;";
57 OS <<
"prepare-for-lto";
67 int Threshold = EnableHeaderDuplication ||
71 const DataLayout &
DL = L.getHeader()->getModule()->getDataLayout();
74 std::optional<MemorySSAUpdater> MSSAU;
78 MSSAU ? &*MSSAU :
nullptr, SQ,
false, Threshold,
95class LoopRotateLegacyPass :
public LoopPass {
96 unsigned MaxHeaderSize;
101 LoopRotateLegacyPass(
int SpecifiedMaxHeaderSize = -1,
102 bool PrepareForLTO =
false)
103 :
LoopPass(
ID), PrepareForLTO(PrepareForLTO) {
105 if (SpecifiedMaxHeaderSize == -1)
108 MaxHeaderSize =
unsigned(SpecifiedMaxHeaderSize);
129 auto *LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
130 const auto *
TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(
F);
131 auto *AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(
F);
132 auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
133 auto &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
135 std::optional<MemorySSAUpdater> MSSAU;
138 auto *MSSAA = getAnalysisIfAvailable<MemorySSAWrapperPass>();
148 return LoopRotation(L, LI,
TTI, AC, &DT, &SE, MSSAU ? &*MSSAU :
nullptr, SQ,
149 false, Threshold,
false,
155char LoopRotateLegacyPass::ID = 0;
166 return new LoopRotateLegacyPass(MaxHeaderSize, PrepareForLTO);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static cl::opt< unsigned > DefaultRotationThreshold("rotation-max-header-size", cl::init(16), cl::Hidden, cl::desc("The default maximum header size for automatic loop rotation"))
static cl::opt< bool > PrepareForLTOOption("rotation-prepare-for-lto", cl::init(false), cl::Hidden, cl::desc("Run loop-rotation in the prepare-for-lto stage. This option " "should be used for testing only."))
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
A container for analyses that lazily runs them and caches their results.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
An immutable pass that tracks lazily created AssumptionCache objects.
A parsed version of the target data layout string in and methods for querying it.
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
This is an alternative analysis pass to BlockFrequencyInfoWrapperPass.
This is an alternative analysis pass to BranchProbabilityInfoWrapperPass.
LoopRotatePass(bool EnableHeaderDuplication=true, bool PrepareForLTO=false)
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U)
Represents a single loop in the control flow graph.
An analysis that produces MemorySSA for a function.
Legacy analysis pass which computes MemorySSA.
void verifyMemorySSA(VerificationLevel=VerificationLevel::Fast) const
Verify that MemorySSA is self consistent (IE definitions dominate all uses, uses appear in the right ...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Pass interface - Implemented by all 'passes'.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
StringRef - Represent a constant reference to a string, i.e.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
Pass * createLoopRotatePass(int MaxHeaderSize=-1, bool PrepareForLTO=false)
TransformationMode hasVectorizeTransformation(const Loop *L)
void getLoopAnalysisUsage(AnalysisUsage &AU)
Helper to consistently add the set of standard passes to a loop pass's AnalysisUsage.
bool VerifyMemorySSA
Enables verification of MemorySSA.
@ TM_ForcedByUser
The transformation was directed by the user, e.g.
PreservedAnalyses getLoopPassPreservedAnalyses()
Returns the minimum set of Analyses that all loop passes must preserve.
void initializeLoopRotateLegacyPassPass(PassRegistry &)
const SimplifyQuery getBestSimplifyQuery(Pass &, Function &)
bool LoopRotation(Loop *L, LoopInfo *LI, const TargetTransformInfo *TTI, AssumptionCache *AC, DominatorTree *DT, ScalarEvolution *SE, MemorySSAUpdater *MSSAU, const SimplifyQuery &SQ, bool RotationOnly, unsigned Threshold, bool IsUtilMode, bool PrepareForLTO=false)
Convert a loop into a loop with bottom test.
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
TargetTransformInfo & TTI
A CRTP mix-in to automatically provide informational APIs needed for passes.