[llvm] [LV][NFC]Introduce isScalableVectorizationAllowed() to refactor getMaxLegalScalableVF(). (PR #98916)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 16 09:33:49 PDT 2024


================
@@ -4183,17 +4193,32 @@ LoopVectorizationCostModel::getMaxLegalScalableVF(unsigned MaxSafeElements) {
     reportVectorizationInfo("Scalable vectorization is not supported "
                             "for all element types found in this loop.",
                             "ScalableVFUnfeasible", ORE, TheLoop);
-    return ElementCount::getScalable(0);
+    return false;
   }
 
+  IsScalableVectorizationAllowed = true;
+  return true;
+}
+
+ElementCount
+LoopVectorizationCostModel::getMaxLegalScalableVF(unsigned MaxSafeElements) {
+  if (!isScalableVectorizationAllowed())
+    return ElementCount::getScalable(0);
+
+  auto MaxScalableVF = ElementCount::getScalable(
+      std::numeric_limits<ElementCount::ScalarTy>::max());
   if (Legal->isSafeForAnyVectorWidth())
     return MaxScalableVF;
 
+  std::optional<unsigned> MaxVScale = getMaxVScale(*TheFunction, TTI);
+  if (!MaxVScale) {
+    reportVectorizationInfo("The target does not provide maximum vscale value.",
+                            "ScalableVFUnfeasible", ORE, TheLoop);
----------------
ayalz wrote:

Thanks for separating this message from the one below!

Does this !MaxVScale case better belong earlier, in isScalableVectorizationAllowed()?

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


More information about the llvm-commits mailing list