diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-04-14 21:41:27 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-06-22 18:20:56 +0000 |
commit | bdd1243df58e60e85101c09001d9812a789b6bc4 (patch) | |
tree | a1ce621c7301dd47ba2ddc3b8eaa63b441389481 /contrib/llvm-project/llvm/lib/Analysis/LoopCacheAnalysis.cpp | |
parent | 781624ca2d054430052c828ba8d2c2eaf2d733e7 (diff) | |
parent | e3b557809604d036af6e00c60f012c2025b59a5e (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Analysis/LoopCacheAnalysis.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Analysis/LoopCacheAnalysis.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/contrib/llvm-project/llvm/lib/Analysis/LoopCacheAnalysis.cpp b/contrib/llvm-project/llvm/lib/Analysis/LoopCacheAnalysis.cpp index 85f2dad86711..46198f78b643 100644 --- a/contrib/llvm-project/llvm/lib/Analysis/LoopCacheAnalysis.cpp +++ b/contrib/llvm-project/llvm/lib/Analysis/LoopCacheAnalysis.cpp @@ -156,9 +156,9 @@ IndexedReference::IndexedReference(Instruction &StoreOrLoadInst, << "\n"); } -Optional<bool> IndexedReference::hasSpacialReuse(const IndexedReference &Other, - unsigned CLS, - AAResults &AA) const { +std::optional<bool> +IndexedReference::hasSpacialReuse(const IndexedReference &Other, unsigned CLS, + AAResults &AA) const { assert(IsValid && "Expecting a valid reference"); if (BasePointer != Other.getBasePointer() && !isAliased(Other, AA)) { @@ -196,7 +196,7 @@ Optional<bool> IndexedReference::hasSpacialReuse(const IndexedReference &Other, << "No spacial reuse, difference between subscript:\n\t" << *LastSubscript << "\n\t" << OtherLastSubscript << "\nis not constant.\n"); - return None; + return std::nullopt; } bool InSameCacheLine = (Diff->getValue()->getSExtValue() < CLS); @@ -211,11 +211,10 @@ Optional<bool> IndexedReference::hasSpacialReuse(const IndexedReference &Other, return InSameCacheLine; } -Optional<bool> IndexedReference::hasTemporalReuse(const IndexedReference &Other, - unsigned MaxDistance, - const Loop &L, - DependenceInfo &DI, - AAResults &AA) const { +std::optional<bool> +IndexedReference::hasTemporalReuse(const IndexedReference &Other, + unsigned MaxDistance, const Loop &L, + DependenceInfo &DI, AAResults &AA) const { assert(IsValid && "Expecting a valid reference"); if (BasePointer != Other.getBasePointer() && !isAliased(Other, AA)) { @@ -248,7 +247,7 @@ Optional<bool> IndexedReference::hasTemporalReuse(const IndexedReference &Other, if (SCEVConst == nullptr) { LLVM_DEBUG(dbgs().indent(2) << "No temporal reuse: distance unknown\n"); - return None; + return std::nullopt; } const ConstantInt &CI = *SCEVConst->getValue(); @@ -557,10 +556,10 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const CacheCost &CC) { CacheCost::CacheCost(const LoopVectorTy &Loops, const LoopInfo &LI, ScalarEvolution &SE, TargetTransformInfo &TTI, - AAResults &AA, DependenceInfo &DI, Optional<unsigned> TRT) - : Loops(Loops), - TRT((TRT == None) ? Optional<unsigned>(TemporalReuseThreshold) : TRT), - LI(LI), SE(SE), TTI(TTI), AA(AA), DI(DI) { + AAResults &AA, DependenceInfo &DI, + std::optional<unsigned> TRT) + : Loops(Loops), TRT(TRT.value_or(TemporalReuseThreshold)), LI(LI), SE(SE), + TTI(TTI), AA(AA), DI(DI) { assert(!Loops.empty() && "Expecting a non-empty loop vector."); for (const Loop *L : Loops) { @@ -574,7 +573,7 @@ CacheCost::CacheCost(const LoopVectorTy &Loops, const LoopInfo &LI, std::unique_ptr<CacheCost> CacheCost::getCacheCost(Loop &Root, LoopStandardAnalysisResults &AR, - DependenceInfo &DI, Optional<unsigned> TRT) { + DependenceInfo &DI, std::optional<unsigned> TRT) { if (!Root.isOutermost()) { LLVM_DEBUG(dbgs() << "Expecting the outermost loop in a loop nest\n"); return nullptr; @@ -649,9 +648,9 @@ bool CacheCost::populateReferenceGroups(ReferenceGroupsTy &RefGroups) const { // when in actuality, depending on the array size, the first example // should have a cost closer to 2x the second due to the two cache // access per iteration from opposite ends of the array - Optional<bool> HasTemporalReuse = + std::optional<bool> HasTemporalReuse = R->hasTemporalReuse(Representative, *TRT, *InnerMostLoop, DI, AA); - Optional<bool> HasSpacialReuse = + std::optional<bool> HasSpacialReuse = R->hasSpacialReuse(Representative, CLS, AA); if ((HasTemporalReuse && *HasTemporalReuse) || |