[llvm] [LV] Prefer fixed VFs for epilogue vectorization (PR #211814)
Benjamin Maxwell via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 7 06:45:34 PDT 2026
================
@@ -706,6 +710,23 @@ bool LoopVectorizationPlanner::isMoreProfitable(const VectorizationFactor &A,
!B.Width.isScalar())
return true;
+ // Favor fixed VFs for epilogue loops by scaling the costs of scalable VFs
+ // 'ScalableEpilogueVFCostScaleFactor' (default 2.0). This is intended to
+ // model that fixed VFs are more likely to be fully unrolled (or optimized
+ // out) post vectorization. TODO: Reconsider this restriction for predicated
+ // epilogues (once supported).
+ if (IsEpilogue && A.Width.isScalable() != B.Width.isScalable() &&
+ A.Cost.isValid() && B.Cost.isValid()) {
+ auto [FixedCost, ScalableCost] = std::make_pair(CostA, CostB);
+ if (B.Width.isFixed())
+ std::swap(FixedCost, ScalableCost);
+
+ ScalableCost *= ScalableEpilogueVFCostScaleFactor.getValue();
----------------
MacDue wrote:
Removed :+1:
https://github.com/llvm/llvm-project/pull/211814
More information about the llvm-commits
mailing list