diff options
| author | Igor Kudrin <ikudrin@accesssoftek.com> | 2022-04-26 18:44:24 +0400 |
|---|---|---|
| committer | Igor Kudrin <ikudrin@accesssoftek.com> | 2022-04-26 18:44:24 +0400 |
| commit | 39ce68886b4900dc63a90e90561ee19f5c7c07dc (patch) | |
| tree | 3b96c6d1da78d28ee192f40d179168ba4561c382 /llvm/lib/Transforms/Utils/LoopPeel.cpp | |
| parent | c71890e158df43d2aa4fbdbfb7adf6791d4cb66b (diff) | |
| download | llvm-39ce68886b4900dc63a90e90561ee19f5c7c07dc.zip llvm-39ce68886b4900dc63a90e90561ee19f5c7c07dc.tar.gz llvm-39ce68886b4900dc63a90e90561ee19f5c7c07dc.tar.bz2 | |
[LoopPeel][NFCI] Simplify the code to calculate peel count for PGO
This reorganizes the code as a preparation for D123865:
* Use more descriptive names for variables
* Simplify a condition by use an already calculated value
for `MaxPeelCount`
* Remove a duplicate log entry
* Report basic values for loop costs
Differential Revision: https://reviews.llvm.org/D124388
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopPeel.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Utils/LoopPeel.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp index 23df7a0..d108fbb 100644 --- a/llvm/lib/Transforms/Utils/LoopPeel.cpp +++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp @@ -460,27 +460,26 @@ void llvm::computePeelCount(Loop *L, unsigned LoopSize, if (L->getHeader()->getParent()->hasProfileData()) { if (violatesLegacyMultiExitLoopCheck(L)) return; - Optional<unsigned> PeelCount = getLoopEstimatedTripCount(L); - if (!PeelCount) + Optional<unsigned> EstimatedTripCount = getLoopEstimatedTripCount(L); + if (!EstimatedTripCount) return; - LLVM_DEBUG(dbgs() << "Profile-based estimated trip count is " << *PeelCount - << "\n"); + LLVM_DEBUG(dbgs() << "Profile-based estimated trip count is " + << *EstimatedTripCount << "\n"); - if (*PeelCount) { - if ((*PeelCount + AlreadyPeeled <= UnrollPeelMaxCount) && - (LoopSize * (*PeelCount + 1) <= Threshold)) { - LLVM_DEBUG(dbgs() << "Peeling first " << *PeelCount - << " iterations.\n"); - PP.PeelCount = *PeelCount; + if (*EstimatedTripCount) { + if (*EstimatedTripCount + AlreadyPeeled <= MaxPeelCount) { + unsigned PeelCount = *EstimatedTripCount; + LLVM_DEBUG(dbgs() << "Peeling first " << PeelCount << " iterations.\n"); + PP.PeelCount = PeelCount; return; } - LLVM_DEBUG(dbgs() << "Requested peel count: " << *PeelCount << "\n"); LLVM_DEBUG(dbgs() << "Already peel count: " << AlreadyPeeled << "\n"); LLVM_DEBUG(dbgs() << "Max peel count: " << UnrollPeelMaxCount << "\n"); - LLVM_DEBUG(dbgs() << "Peel cost: " << LoopSize * (*PeelCount + 1) - << "\n"); + LLVM_DEBUG(dbgs() << "Loop cost: " << LoopSize << "\n"); LLVM_DEBUG(dbgs() << "Max peel cost: " << Threshold << "\n"); + LLVM_DEBUG(dbgs() << "Max peel count by cost: " + << (Threshold / LoopSize - 1) << "\n"); } } } |
