[llvm] [LoopVectorize][NFC] Rewrite tests to check output of vplan cost model (PR #113697)

David Green via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 14 00:18:51 PST 2024


================
@@ -7382,7 +7382,15 @@ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan,
 
   // Now compute and add the VPlan-based cost.
   Cost += Plan.cost(VF, CostCtx);
-  LLVM_DEBUG(dbgs() << "Cost for VF " << VF << ": " << Cost << "\n");
+#ifndef NDEBUG
+  unsigned EstimatedWidth = VF.getKnownMinValue();
+  if (VF.isScalable())
+    if (std::optional<unsigned> VScale = getVScaleForTuning(OrigLoop, TTI))
+      EstimatedWidth *= *VScale;
+  LLVM_DEBUG(dbgs() << "Cost for VF " << VF << ": " << Cost
+                    << " (Estimated cost per lane: " << (Cost / EstimatedWidth)
----------------
davemgreen wrote:

Could we make this a float? The cost calc will consider fractions I believe (although it will do it the other way around).

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


More information about the llvm-commits mailing list