[llvm] [LV] Modify the tie-breaker logic of `preferscalable` in isMoreProfitable(). (PR #121682)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 5 21:39:58 PST 2025


================
@@ -4373,8 +4373,12 @@ bool LoopVectorizationPlanner::isMoreProfitable(
   // Assume vscale may be larger than 1 (or the value being tuned for),
   // so that scalable vectorization is slightly favorable over fixed-width
   // vectorization.
-  bool PreferScalable = !TTI.preferFixedOverScalableIfEqualCost() &&
-                        A.Width.isScalable() && !B.Width.isScalable();
+
+  // Only check preferFixedOverScalableIfEqualCost() when A is scalable
+  // but B isn't.
+  bool PreferScalable = true;
+  if (A.Width.isScalable() && !B.Width.isScalable())
+    PreferScalable = !TTI.preferFixedOverScalableIfEqualCost();
 
----------------
Tomlord1122 wrote:

Thanks for your response. So what you mean is that in this case:

A's VF = 1, cost = 4
B's VF = vscale × 2, cost = 4
Decision: Vectorize.

Maybe the vectorizer should not vectorize in this case?

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


More information about the llvm-commits mailing list