Go to the documentation of this file.
14 #ifndef LLVM_ANALYSIS_LOOPCACHEANALYSIS_H
15 #define LLVM_ANALYSIS_LOOPCACHEANALYSIS_H
29 class ScalarEvolution;
31 class TargetTransformInfo;
60 return Subscripts[SubNum];
63 assert(!Subscripts.empty() &&
"Expecting non-empty container");
64 return Subscripts.front();
67 assert(!Subscripts.empty() &&
"Expecting non-empty container");
68 return Subscripts.back();
83 unsigned MaxDistance,
const Loop &L,
99 bool delinearize(
const LoopInfo &LI);
102 const SCEV *SrcAccessFn,
106 bool isLoopInvariant(
const Loop &L)
const;
112 bool isConsecutive(
const Loop &L,
unsigned CLS)
const;
119 int getSubscriptIndex(
const Loop &L)
const;
122 const SCEV *getLastCoefficient()
const;
126 bool isCoeffForLoopZeroOrInvariant(
const SCEV &Subscript,
127 const Loop &L)
const;
131 bool isSimpleAddRecurrence(
const SCEV &Subscript,
const Loop &L)
const;
139 bool IsValid =
false;
145 const SCEV *BasePointer =
nullptr;
189 using LoopTripCountTy = std::pair<const Loop *, unsigned>;
190 using LoopCacheCostTy = std::pair<const Loop *, CacheCostTy>;
207 static std::unique_ptr<CacheCost>
215 return LCC.first == &L;
217 return (
IT != LoopCosts.end()) ? (*IT).second : -1;
226 void calculateCacheFootprint();
249 const Loop &L)
const;
252 void sortLoopCosts() {
254 [](
const LoopCacheCostTy &A,
const LoopCacheCostTy &
B) {
255 return A.second >
B.second;
264 SmallVector<LoopTripCountTy, 3> TripCounts;
267 SmallVector<LoopCacheCostTy, 3> LoopCosts;
271 Optional<unsigned> TRT;
275 TargetTransformInfo &TTI;
280 raw_ostream &
operator<<(raw_ostream &OS,
const IndexedReference &R);
281 raw_ostream &
operator<<(raw_ostream &OS,
const CacheCost &CC);
296 #endif // LLVM_ANALYSIS_LOOPCACHEANALYSIS_H
A set of analyses that are preserved following a run of a transformation pass.
This is an optimization pass for GlobalISel generic memory operations.
Optional< bool > hasSpacialReuse(const IndexedReference &Other, unsigned CLS, AAResults &AA) const
Return true/false if the current object and the indexed reference Other are/aren't in the same cache ...
A CRTP mix-in to automatically provide informational APIs needed for passes.
const SCEV * getSubscript(unsigned SubNum) const
Represents a single loop in the control flow graph.
ArrayRef< LoopCacheCostTy > getLoopCosts() const
Return the estimated ordered loop costs.
The main scalar evolution driver.
friend raw_ostream & operator<<(raw_ostream &OS, const CacheCost &CC)
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
CacheCostTy getLoopCost(const Loop &L) const
Return the estimated cost of loop L if the given loop is part of the loop nest associated with this o...
const SCEV * getFirstSubscript() const
Printer pass for the CacheCost results.
static std::unique_ptr< CacheCost > getCacheCost(Loop &Root, LoopStandardAnalysisResults &AR, DependenceInfo &DI, Optional< unsigned > TRT=None)
Create a CacheCost for the loop nest rooted by Root.
SmallVector< Loop *, 8 > LoopVectorTy
size_t getNumSubscripts() const
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
CacheCostTy computeRefCost(const Loop &L, unsigned CLS) const
Compute the cost of the reference w.r.t.
This class implements an extremely fast bulk output stream that can only output to a stream.
Optional< bool > hasTemporalReuse(const IndexedReference &Other, unsigned MaxDistance, const Loop &L, DependenceInfo &DI, AAResults &AA) const
Return true if the current object and the indexed reference Other have distance smaller than MaxDista...
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
IndexedReference(Instruction &StoreOrLoadInst, const LoopInfo &LI, ScalarEvolution &SE)
Construct an indexed reference given a StoreOrLoadInst instruction.
This class represents an analyzed expression in the program.
DependenceInfo - This class is the main dependence-analysis driver.
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
Represents a memory reference as a base pointer and a set of indexing operations.
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::ZeroOrMore, cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const SCEV * getLastSubscript() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
friend raw_ostream & operator<<(raw_ostream &OS, const IndexedReference &R)
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
void stable_sort(R &&Range)
LoopCachePrinterPass(raw_ostream &OS)
const SCEV * getBasePointer() const
CacheCost represents the estimated cost of a inner loop as the number of cache lines used by the memo...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
A container for analyses that lazily runs them and caches their results.
static constexpr CacheCostTy InvalidCost
CacheCost(const LoopVectorTy &Loops, const LoopInfo &LI, ScalarEvolution &SE, TargetTransformInfo &TTI, AAResults &AA, DependenceInfo &DI, Optional< unsigned > TRT=None)
Construct a CacheCost object for the loop nest described by Loops.