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

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 15 02:20:29 PDT 2025


================
@@ -4189,27 +4184,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;
-    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);
-
-    // Select the largest VF which doesn't require more registers than existing
-    // ones.
-    for (int I = RUs.size() - 1; I >= 0; --I) {
-      const auto &MLU = RUs[I].MaxLocalUsers;
-      if (all_of(MLU, [&](decltype(MLU.front()) &LU) {
-            return LU.second <= TTI.getNumberOfRegisters(LU.first);
-          })) {
-        MaxVF = VFs[I];
-        break;
-      }
-    }
+    // Set the max VF to the largest viable vectorization factor less than or
+    // equal to the max vector element count.
+    if (ElementCount::isKnownLE(MaxVectorElementCount,
+                                MaxVectorElementCountMaxBW))
----------------
sdesmalen-arm wrote:

Is this condition ever false?

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


More information about the llvm-commits mailing list