[llvm] LV: reuse getSmallBestKnownTC in RT-check TC estimation (PR #105834)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 23 06:59:44 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Ramkumar Ramachandra (artagnon)
<details>
<summary>Changes</summary>
GeneratedRTChecks::getCost duplicates getSmallBestKnownTC partially, when attempting to get the best trip-count estimate. Since the intent of this code is to get the best trip-count estimate, and getSmallBestKnownTC is written for exactly this purpose, replace the partial code-duplication with a call to this function.
---
Full diff: https://github.com/llvm/llvm-project/pull/105834.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+3-8)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 2145bb8c9ca872..c1135e81feb33d 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1971,14 +1971,9 @@ class GeneratedRTChecks {
// count. Assume that the outer loop executes at least twice.
unsigned BestTripCount = 2;
- // If exact trip count is known use that.
- if (unsigned SmallTC = SE->getSmallConstantTripCount(OuterLoop))
- BestTripCount = SmallTC;
- else if (LoopVectorizeWithBlockFrequency) {
- // Else use profile data if available.
- if (auto EstimatedTC = getLoopEstimatedTripCount(OuterLoop))
- BestTripCount = *EstimatedTC;
- }
+ // Get the best known TC estimate.
+ if (auto EstimatedTC = getSmallBestKnownTC(*SE, OuterLoop))
+ BestTripCount = *EstimatedTC;
BestTripCount = std::max(BestTripCount, 1U);
InstructionCost NewMemCheckCost = MemCheckCost / BestTripCount;
``````````
</details>
https://github.com/llvm/llvm-project/pull/105834
More information about the llvm-commits
mailing list