[llvm] [LV] Incorporate trip counts into selection of scalable VFs (PR #80926)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 06:47:47 PST 2024


================
@@ -4933,11 +4933,17 @@ bool LoopVectorizationPlanner::isMoreProfitable(
       EstimatedWidthB *= *VScale;
   }
 
+  if (MaxTripCount > 0) {
+    EstimatedWidthA = std::min(EstimatedWidthA, MaxTripCount);
----------------
fhahn wrote:

`LoopVectorizationCostModel::getMaximizedVFForTarget` should limit the maximum VFs so that no VF exceeds at the loop's trip count. Would it be possible to handle minimum VSCale there instead?

There's already accounts for the `vscale` function attribute there

```
  unsigned WidestRegisterMinEC = MaxVectorElementCount.getKnownMinValue();
  if (MaxVectorElementCount.isScalable() &&
      TheFunction->hasFnAttribute(Attribute::VScaleRange)) {
    auto Attr = TheFunction->getFnAttribute(Attribute::VScaleRange);
    auto Min = Attr.getVScaleRangeMin();
    WidestRegisterMinEC *= Min;
  }
```

also cc @david-arm 

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


More information about the llvm-commits mailing list