14#ifndef LLVM_ANALYSIS_LOOPCACHEANALYSIS_H
15#define LLVM_ANALYSIS_LOOPCACHEANALYSIS_H
32class TargetTransformInfo;
61 return Subscripts[SubNum];
64 assert(!Subscripts.empty() &&
"Expecting non-empty container");
65 return Subscripts.front();
68 assert(!Subscripts.empty() &&
"Expecting non-empty container");
69 return Subscripts.back();
84 unsigned MaxDistance,
const Loop &L,
100 bool delinearize(
const LoopInfo &LI);
103 bool tryDelinearizeFixedSize(
const SCEV *AccessFn,
107 bool isLoopInvariant(
const Loop &L)
const;
114 bool isConsecutive(
const Loop &L,
const SCEV *&Stride,
unsigned CLS)
const;
121 int getSubscriptIndex(
const Loop &L)
const;
124 const SCEV *getLastCoefficient()
const;
128 bool isCoeffForLoopZeroOrInvariant(
const SCEV &Subscript,
129 const Loop &L)
const;
133 bool isSimpleAddRecurrence(
const SCEV &Subscript,
const Loop &L)
const;
141 bool IsValid =
false;
147 const SCEV *BasePointer =
nullptr;
191 using LoopTripCountTy = std::pair<const Loop *, unsigned>;
192 using LoopCacheCostTy = std::pair<const Loop *, CacheCostTy>;
203 std::optional<unsigned> TRT = std::nullopt);
209 static std::unique_ptr<CacheCost>
211 std::optional<unsigned> TRT = std::nullopt);
217 return LCC.first == &L;
219 return (
IT != LoopCosts.
end()) ? (*IT).second : -1;
228 void calculateCacheFootprint();
251 const Loop &L)
const;
254 void sortLoopCosts() {
256 [](
const LoopCacheCostTy &
A,
const LoopCacheCostTy &
B) {
257 return A.second >
B.second;
266 SmallVector<LoopTripCountTy, 3> TripCounts;
269 SmallVector<LoopCacheCostTy, 3> LoopCosts;
273 std::optional<unsigned> TRT;
277 TargetTransformInfo &TTI;
282raw_ostream &
operator<<(raw_ostream &
OS,
const IndexedReference &R);
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This header provides classes for managing per-loop analyses.
This header defines various interfaces for pass management in LLVM.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A container for analyses that lazily runs them and caches their results.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
CacheCost represents the estimated cost of a inner loop as the number of cache lines used by the memo...
ArrayRef< LoopCacheCostTy > getLoopCosts() const
Return the estimated ordered loop costs.
static std::unique_ptr< CacheCost > getCacheCost(Loop &Root, LoopStandardAnalysisResults &AR, DependenceInfo &DI, std::optional< unsigned > TRT=std::nullopt)
Create a CacheCost for the loop nest rooted by Root.
friend raw_ostream & operator<<(raw_ostream &OS, const CacheCost &CC)
static CacheCostTy constexpr InvalidCost
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...
DependenceInfo - This class is the main dependence-analysis driver.
Represents a memory reference as a base pointer and a set of indexing operations.
const SCEV * getBasePointer() const
CacheCostTy computeRefCost(const Loop &L, unsigned CLS) const
Compute the cost of the reference w.r.t.
const SCEV * getSubscript(unsigned SubNum) const
const SCEV * getFirstSubscript() const
friend raw_ostream & operator<<(raw_ostream &OS, const IndexedReference &R)
std::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 ...
std::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...
const SCEV * getLastSubscript() const
size_t getNumSubscripts() const
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
Printer pass for the CacheCost results.
LoopCachePrinterPass(raw_ostream &OS)
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U)
Represents a single loop in the control flow graph.
A set of analyses that are preserved following a run of a transformation pass.
This class represents an analyzed expression in the program.
The main scalar evolution driver.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
void stable_sort(R &&Range)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
SmallVector< Loop *, 8 > LoopVectorTy
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
A CRTP mix-in to automatically provide informational APIs needed for passes.