[llvm] [LV][NFC] Simplify initialization of MinProfitableTripCount (PR #113445)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 23 04:31:12 PDT 2024


https://github.com/Mel-Chen created https://github.com/llvm/llvm-project/pull/113445

Iteration runtime check confirms whether the trip count is greater than VFxUF at least. Therefore, there is no need to adjust the MinProfitableTripCount to VFxUF if it is zero.
Retaining the original MinProfitableTripCount information is also beneficial for supporting more profitable runtime checks in the future.

>From 938f7ded35c899cac538a57016f8157c0a340562 Mon Sep 17 00:00:00 2001
From: Mel Chen <mel.chen at sifive.com>
Date: Wed, 23 Oct 2024 04:01:44 -0700
Subject: [PATCH] [LV][NFC] Simplify initialization of MinProfitableTripCount

Iteration runtime check confirms whether the trip count is greater than
VFxUF at least. Therefore, there is no need to adjust the
MinProfitableTripCount to VFxUF if it is zero.

Retaining the original MinProfitableTripCount information is also
beneficial for supporting more profitable runtime checks in the future.
---
 llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 60a94ca1f86e42..804b541e8ffdec 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -469,18 +469,14 @@ class InnerLoopVectorizer {
                       LoopVectorizationCostModel *CM, BlockFrequencyInfo *BFI,
                       ProfileSummaryInfo *PSI, GeneratedRTChecks &RTChecks)
       : OrigLoop(OrigLoop), PSE(PSE), LI(LI), DT(DT), TLI(TLI), TTI(TTI),
-        AC(AC), ORE(ORE), VF(VecWidth), UF(UnrollFactor),
+        AC(AC), ORE(ORE), VF(VecWidth),
+        MinProfitableTripCount(MinProfitableTripCount), UF(UnrollFactor),
         Builder(PSE.getSE()->getContext()), Legal(LVL), Cost(CM), BFI(BFI),
         PSI(PSI), RTChecks(RTChecks) {
     // Query this against the original loop and save it here because the profile
     // of the original loop header may change as the transformation happens.
     OptForSizeBasedOnProfile = llvm::shouldOptimizeForSize(
         OrigLoop->getHeader(), PSI, BFI, PGSOQueryType::IRPass);
-
-    if (MinProfitableTripCount.isZero())
-      this->MinProfitableTripCount = VecWidth;
-    else
-      this->MinProfitableTripCount = MinProfitableTripCount;
   }
 
   virtual ~InnerLoopVectorizer() = default;



More information about the llvm-commits mailing list