[llvm] [LLVM][LV] Improve UF calculation for vscale based scalar loops. (PR #146102)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 9 12:02:42 PDT 2025


================
@@ -4813,16 +4832,22 @@ LoopVectorizationCostModel::selectInterleaveCount(VPlan &Plan, ElementCount VF,
       MaxInterleaveCount = ForceTargetMaxVectorInterleaveFactor;
   }
 
-  unsigned EstimatedVF = getEstimatedRuntimeVF(VF, VScaleForTuning);
-
   // Try to get the exact trip count, or an estimate based on profiling data or
   // ConstantMax from PSE, failing that.
-  if (auto BestKnownTC = getSmallBestKnownTC(PSE, TheLoop)) {
+  auto BestKnownTC = getSmallBestKnownTC(PSE, TheLoop);
+
+  // For fixed length VFs treat a scalable trip count as unknown.
+  if (BestKnownTC && (BestKnownTC->isFixed() || VF.isScalable())) {
----------------
preames wrote:

Style wise: 
if (auto BestKnownTC = getSmallBestKnownTC(PSE, TheLoop);
   BestKnownTC && (BestKnownTC->isFixed() || VF.isScalable())) {


https://github.com/llvm/llvm-project/pull/146102


More information about the llvm-commits mailing list