diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/llvm12/lib/Transforms/Scalar/LoopLoadElimination.cpp | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/Transforms/Scalar/LoopLoadElimination.cpp')
-rw-r--r-- | contrib/libs/llvm12/lib/Transforms/Scalar/LoopLoadElimination.cpp | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/contrib/libs/llvm12/lib/Transforms/Scalar/LoopLoadElimination.cpp b/contrib/libs/llvm12/lib/Transforms/Scalar/LoopLoadElimination.cpp index 058612149a..0d3f053e1e 100644 --- a/contrib/libs/llvm12/lib/Transforms/Scalar/LoopLoadElimination.cpp +++ b/contrib/libs/llvm12/lib/Transforms/Scalar/LoopLoadElimination.cpp @@ -55,7 +55,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils.h" -#include "llvm/Transforms/Utils/LoopSimplify.h" +#include "llvm/Transforms/Utils/LoopSimplify.h" #include "llvm/Transforms/Utils/LoopVersioning.h" #include "llvm/Transforms/Utils/ScalarEvolutionExpander.h" #include "llvm/Transforms/Utils/SizeOpts.h" @@ -308,8 +308,8 @@ public: /// We need a check if one is a pointer for a candidate load and the other is /// a pointer for a possibly intervening store. bool needsChecking(unsigned PtrIdx1, unsigned PtrIdx2, - const SmallPtrSetImpl<Value *> &PtrsWrittenOnFwdingPath, - const SmallPtrSetImpl<Value *> &CandLoadPtrs) { + const SmallPtrSetImpl<Value *> &PtrsWrittenOnFwdingPath, + const SmallPtrSetImpl<Value *> &CandLoadPtrs) { Value *Ptr1 = LAI.getRuntimePointerChecking()->getPointerInfo(PtrIdx1).PointerValue; Value *Ptr2 = @@ -384,9 +384,9 @@ public: findPointersWrittenOnForwardingPath(Candidates); // Collect the pointers of the candidate loads. - SmallPtrSet<Value *, 4> CandLoadPtrs; - for (const auto &Candidate : Candidates) - CandLoadPtrs.insert(Candidate.getLoadPtr()); + SmallPtrSet<Value *, 4> CandLoadPtrs; + for (const auto &Candidate : Candidates) + CandLoadPtrs.insert(Candidate.getLoadPtr()); const auto &AllChecks = LAI.getRuntimePointerChecking()->getChecks(); SmallVector<RuntimePointerCheck, 4> Checks; @@ -505,16 +505,16 @@ public: if (!Cand.isDependenceDistanceOfOne(PSE, L)) continue; - assert(isa<SCEVAddRecExpr>(PSE.getSCEV(Cand.Load->getPointerOperand())) && - "Loading from something other than indvar?"); - assert( - isa<SCEVAddRecExpr>(PSE.getSCEV(Cand.Store->getPointerOperand())) && - "Storing to something other than indvar?"); - - Candidates.push_back(Cand); + assert(isa<SCEVAddRecExpr>(PSE.getSCEV(Cand.Load->getPointerOperand())) && + "Loading from something other than indvar?"); + assert( + isa<SCEVAddRecExpr>(PSE.getSCEV(Cand.Store->getPointerOperand())) && + "Storing to something other than indvar?"); + + Candidates.push_back(Cand); LLVM_DEBUG( dbgs() - << Candidates.size() + << Candidates.size() << ". Valid store-to-load forwarding across the loop backedge\n"); } if (Candidates.empty()) @@ -563,19 +563,19 @@ public: // Point of no-return, start the transformation. First, version the loop // if necessary. - LoopVersioning LV(LAI, Checks, L, LI, DT, PSE.getSE()); + LoopVersioning LV(LAI, Checks, L, LI, DT, PSE.getSE()); LV.versionLoop(); - - // After versioning, some of the candidates' pointers could stop being - // SCEVAddRecs. We need to filter them out. - auto NoLongerGoodCandidate = [this]( - const StoreToLoadForwardingCandidate &Cand) { - return !isa<SCEVAddRecExpr>( - PSE.getSCEV(Cand.Load->getPointerOperand())) || - !isa<SCEVAddRecExpr>( - PSE.getSCEV(Cand.Store->getPointerOperand())); - }; - llvm::erase_if(Candidates, NoLongerGoodCandidate); + + // After versioning, some of the candidates' pointers could stop being + // SCEVAddRecs. We need to filter them out. + auto NoLongerGoodCandidate = [this]( + const StoreToLoadForwardingCandidate &Cand) { + return !isa<SCEVAddRecExpr>( + PSE.getSCEV(Cand.Load->getPointerOperand())) || + !isa<SCEVAddRecExpr>( + PSE.getSCEV(Cand.Store->getPointerOperand())); + }; + llvm::erase_if(Candidates, NoLongerGoodCandidate); } // Next, propagate the value stored by the store to the users of the load. @@ -584,7 +584,7 @@ public: "storeforward"); for (const auto &Cand : Candidates) propagateStoredValueToLoadUsers(Cand, SEE); - NumLoopLoadEliminted += Candidates.size(); + NumLoopLoadEliminted += Candidates.size(); return true; } @@ -610,7 +610,7 @@ private: static bool eliminateLoadsAcrossLoops(Function &F, LoopInfo &LI, DominatorTree &DT, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, - ScalarEvolution *SE, AssumptionCache *AC, + ScalarEvolution *SE, AssumptionCache *AC, function_ref<const LoopAccessInfo &(Loop &)> GetLAI) { // Build up a worklist of inner-loops to transform to avoid iterator // invalidation. @@ -619,21 +619,21 @@ eliminateLoadsAcrossLoops(Function &F, LoopInfo &LI, DominatorTree &DT, // which merely optimizes the use of loads in a loop. SmallVector<Loop *, 8> Worklist; - bool Changed = false; - + bool Changed = false; + for (Loop *TopLevelLoop : LI) - for (Loop *L : depth_first(TopLevelLoop)) { - Changed |= simplifyLoop(L, &DT, &LI, SE, AC, /*MSSAU*/ nullptr, false); + for (Loop *L : depth_first(TopLevelLoop)) { + Changed |= simplifyLoop(L, &DT, &LI, SE, AC, /*MSSAU*/ nullptr, false); // We only handle inner-most loops. - if (L->isInnermost()) + if (L->isInnermost()) Worklist.push_back(L); - } + } // Now walk the identified inner loops. for (Loop *L : Worklist) { - // Match historical behavior - if (!L->isRotatedForm() || !L->getExitingBlock()) - continue; + // Match historical behavior + if (!L->isRotatedForm() || !L->getExitingBlock()) + continue; // The actual work is performed by LoadEliminationForLoop. LoadEliminationForLoop LEL(L, &LI, GetLAI(*L), &DT, BFI, PSI); Changed |= LEL.processLoop(); @@ -667,7 +667,7 @@ public: // Process each loop nest in the function. return eliminateLoadsAcrossLoops( - F, LI, DT, BFI, PSI, /*SE*/ nullptr, /*AC*/ nullptr, + F, LI, DT, BFI, PSI, /*SE*/ nullptr, /*AC*/ nullptr, [&LAA](Loop &L) -> const LoopAccessInfo & { return LAA.getInfo(&L); }); } @@ -724,9 +724,9 @@ PreservedAnalyses LoopLoadEliminationPass::run(Function &F, auto &LAM = AM.getResult<LoopAnalysisManagerFunctionProxy>(F).getManager(); bool Changed = eliminateLoadsAcrossLoops( - F, LI, DT, BFI, PSI, &SE, &AC, [&](Loop &L) -> const LoopAccessInfo & { - LoopStandardAnalysisResults AR = {AA, AC, DT, LI, SE, - TLI, TTI, nullptr, MSSA}; + F, LI, DT, BFI, PSI, &SE, &AC, [&](Loop &L) -> const LoopAccessInfo & { + LoopStandardAnalysisResults AR = {AA, AC, DT, LI, SE, + TLI, TTI, nullptr, MSSA}; return LAM.getResult<LoopAccessAnalysis>(L, AR); }); |