[llvm] [LV] Explain why a less profitable VF was chosen (NFCI) (PR #187469)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 19 04:59:29 PDT 2026


================
@@ -3948,8 +3948,10 @@ bool LoopVectorizationPlanner::isMoreProfitable(const VectorizationFactor &A,
   // To avoid the need for FP division:
   //      (CostA / EstimatedWidthA) < (CostB / EstimatedWidthB)
   // <=>  (CostA * EstimatedWidthB) < (CostB * EstimatedWidthA)
+  bool GenerallyLowerCost =
+      CmpFn(CostA * EstimatedWidthB, CostB * EstimatedWidthA);
   if (!MaxTripCount)
-    return CmpFn(CostA * EstimatedWidthB, CostB * EstimatedWidthA);
+    return GenerallyLowerCost;
----------------
sdesmalen-arm wrote:

I'm not sure, when I look for the rationale of the selected VF, I normally search for `Cost for VF X: Y (Estimated cost per lane: Z)`. The idea behind adding this message is because it wasn't explained why it chose a different VF than was obvious from the cost calculations. If it does choose a VF with the lowest cost, that doesn't really need any particular clarification.

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


More information about the llvm-commits mailing list