[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 05:11:34 PST 2024


================
@@ -7403,7 +7404,23 @@ 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: ");
+  if (Cost.isValid()) {
+    std::string CostString;
+    raw_string_ostream CostStream(CostString);
+    double CostPerLane = double(*Cost.getValue()) / EstimatedWidth;
+    llvm::write_double(CostStream, CostPerLane, FloatStyle::Fixed, 1);
----------------
davemgreen wrote:

Could this make use of `dbgs() << format("%1.f", CostPerLane)`?

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


More information about the llvm-commits mailing list