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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 5 11:38:33 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();
 
----------------
fhahn wrote:

I am not sure this is right, and the change in `call_scalarized` doesn't look profitable I think.

Maybe we should only use `<=` if we are comparing 2 vector VFs, where one is scalable? Possible also only if the have the same min number of elements?

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


More information about the llvm-commits mailing list