[llvm] [LoopVectorizer] Prune VFs based on plan register pressure (PR #132190)

Sam Tebbs via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 26 06:57:05 PDT 2025


================
@@ -4240,27 +4235,12 @@ ElementCount LoopVectorizationCostModel::getMaximizedVFForTarget(
         ComputeScalableMaxVF);
     MaxVectorElementCountMaxBW = MinVF(MaxVectorElementCountMaxBW, MaxSafeVF);
 
-    // Collect all viable vectorization factors larger than the default MaxVF
-    // (i.e. MaxVectorElementCount).
-    SmallVector<ElementCount, 8> VFs;
+    // Set the max VF to the largest viable vectorization factor less than or
+    // equal to the max vector element count.
     for (ElementCount VS = MaxVectorElementCount * 2;
          ElementCount::isKnownLE(VS, MaxVectorElementCountMaxBW); VS *= 2)
-      VFs.push_back(VS);
-
-    // For each VF calculate its register usage.
-    auto RUs = calculateRegisterUsage(VFs);
+      MaxVF = VS;
----------------
SamTebbs33 wrote:

I added an assertion checking if `MaxVectorElementCount <= MaxVectorElementCountMaxBW` and an AArch64 test failed (Transforms/LoopVectorize/AArch64/smallest-and-widest-types.ll) so that condition doesn't always hold. So I've replaced the loop with a check and an assignment.

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


More information about the llvm-commits mailing list