[llvm] 3fbae10 - [VPlan] Improve code using m_APInt (NFC) (#161683)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 21 02:27:08 PDT 2025


Author: Ramkumar Ramachandra
Date: 2025-10-21T10:27:03+01:00
New Revision: 3fbae10faaba3de1c87d9af1c986147fb8fd5a42

URL: https://github.com/llvm/llvm-project/commit/3fbae10faaba3de1c87d9af1c986147fb8fd5a42
DIFF: https://github.com/llvm/llvm-project/commit/3fbae10faaba3de1c87d9af1c986147fb8fd5a42.diff

LOG: [VPlan] Improve code using m_APInt (NFC) (#161683)

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 51019eda9c3df..688a013eb353f 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1478,11 +1478,8 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
   if (!Plan.getVectorLoopRegion())
     return false;
 
-  if (!Plan.getTripCount()->isLiveIn())
-    return false;
-  auto *TC = dyn_cast_if_present<ConstantInt>(
-      Plan.getTripCount()->getUnderlyingValue());
-  if (!TC || !BestVF.isFixed())
+  const APInt *TC;
+  if (!BestVF.isFixed() || !match(Plan.getTripCount(), m_APInt(TC)))
     return false;
 
   // Calculate the minimum power-of-2 bit width that can fit the known TC, VF
@@ -1495,7 +1492,7 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
     return std::max<unsigned>(PowerOf2Ceil(MaxVal.getActiveBits()), 8);
   };
   unsigned NewBitWidth =
-      ComputeBitWidth(TC->getValue(), BestVF.getKnownMinValue() * BestUF);
+      ComputeBitWidth(*TC, BestVF.getKnownMinValue() * BestUF);
 
   LLVMContext &Ctx = Plan.getContext();
   auto *NewIVTy = IntegerType::get(Ctx, NewBitWidth);


        


More information about the llvm-commits mailing list