Skip to content

Commit a24d4e1

Browse files
committed
LV: reuse getSmallBestKnownTC in RT-check TC estimation
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.
1 parent 4f07508 commit a24d4e1

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,14 +1971,9 @@ class GeneratedRTChecks {
19711971
// count. Assume that the outer loop executes at least twice.
19721972
unsigned BestTripCount = 2;
19731973

1974-
// If exact trip count is known use that.
1975-
if (unsigned SmallTC = SE->getSmallConstantTripCount(OuterLoop))
1976-
BestTripCount = SmallTC;
1977-
else if (LoopVectorizeWithBlockFrequency) {
1978-
// Else use profile data if available.
1979-
if (auto EstimatedTC = getLoopEstimatedTripCount(OuterLoop))
1980-
BestTripCount = *EstimatedTC;
1981-
}
1974+
// Get the best known TC estimate.
1975+
if (auto EstimatedTC = getSmallBestKnownTC(*SE, OuterLoop))
1976+
BestTripCount = *EstimatedTC;
19821977

19831978
BestTripCount = std::max(BestTripCount, 1U);
19841979
InstructionCost NewMemCheckCost = MemCheckCost / BestTripCount;

0 commit comments

Comments
 (0)