LLVM 22.0.0git
llvm::CacheCost Class Reference

CacheCost represents the estimated cost of a inner loop as the number of cache lines used by the memory references it contains. More...

#include "llvm/Analysis/LoopCacheAnalysis.h"

Public Member Functions

 CacheCost (const LoopVectorTy &Loops, const LoopInfo &LI, ScalarEvolution &SE, TargetTransformInfo &TTI, AAResults &AA, DependenceInfo &DI, std::optional< unsigned > TRT=std::nullopt)
 Construct a CacheCost object for the loop nest described by Loops.
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 object.
ArrayRef< LoopCacheCostTy > getLoopCosts () const
 Return the estimated ordered loop costs.

Static Public Member Functions

static std::unique_ptr< CacheCostgetCacheCost (Loop &Root, LoopStandardAnalysisResults &AR, DependenceInfo &DI, std::optional< unsigned > TRT=std::nullopt)
 Create a CacheCost for the loop nest rooted by Root.

Friends

raw_ostreamoperator<< (raw_ostream &OS, const CacheCost &CC)

Detailed Description

CacheCost represents the estimated cost of a inner loop as the number of cache lines used by the memory references it contains.

The 'cache cost' of a loop 'L' in a loop nest 'LN' is computed as the sum of the cache costs of all of its reference groups when the loop is considered to be in the innermost position in the nest. A reference group represents memory references that fall into the same cache line. Each reference group is analysed with respect to the innermost loop in a loop nest. The cost of a reference is defined as follow:

  • one if it is loop invariant w.r.t the innermost loop,
  • equal to the loop trip count divided by the cache line times the reference stride if the reference stride is less than the cache line size (CLS), and the coefficient of this loop's index variable used in all other subscripts is zero (e.g. RefCost = TripCount/(CLS/RefStride))
  • equal to the innermost loop trip count if the reference stride is greater or equal to the cache line size CLS.

Definition at line 190 of file LoopCacheAnalysis.h.

Constructor & Destructor Documentation

◆ CacheCost()

CacheCost::CacheCost ( const LoopVectorTy & Loops,
const LoopInfo & LI,
ScalarEvolution & SE,
TargetTransformInfo & TTI,
AAResults & AA,
DependenceInfo & DI,
std::optional< unsigned > TRT = std::nullopt )

Construct a CacheCost object for the loop nest described by Loops.

The optional parameter TRT can be used to specify the max. distance between array elements accessed in a loop so that the elements are classified to have temporal reuse.

Definition at line 568 of file LoopCacheAnalysis.cpp.

References assert(), DefaultTripCount, and TemporalReuseThreshold.

Referenced by operator<<.

Member Function Documentation

◆ getCacheCost()

std::unique_ptr< CacheCost > CacheCost::getCacheCost ( Loop & Root,
LoopStandardAnalysisResults & AR,
DependenceInfo & DI,
std::optional< unsigned > TRT = std::nullopt )
static

Create a CacheCost for the loop nest rooted by Root.

The optional parameter TRT can be used to specify the max. distance between array elements accessed in a loop so that the elements are classified to have temporal reuse.

Definition at line 586 of file LoopCacheAnalysis.cpp.

References llvm::LoopStandardAnalysisResults::AA, llvm::append_range(), llvm::breadth_first(), llvm::dbgs(), getInnerMostLoop(), llvm::LoopBase< BlockT, LoopT >::isOutermost(), llvm::LoopStandardAnalysisResults::LI, LLVM_DEBUG, llvm::LoopStandardAnalysisResults::SE, and llvm::LoopStandardAnalysisResults::TTI.

Referenced by llvm::LoopCachePrinterPass::run().

◆ getLoopCost()

CacheCostTy llvm::CacheCost::getLoopCost ( const Loop & L) const
inline

Return the estimated cost of loop L if the given loop is part of the loop nest associated with this object.

Return -1 otherwise.

Definition at line 214 of file LoopCacheAnalysis.h.

References llvm::find_if(), and IT.

◆ getLoopCosts()

ArrayRef< LoopCacheCostTy > llvm::CacheCost::getLoopCosts ( ) const
inline

Return the estimated ordered loop costs.

Definition at line 222 of file LoopCacheAnalysis.h.

◆ operator<<

raw_ostream & operator<< ( raw_ostream & OS,
const CacheCost & CC )
friend

References CacheCost().


The documentation for this class was generated from the following files: