[llvm] [LV][NFC] Use APFloat class when printing out costs per lane (PR #201824)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 10 05:06:48 PDT 2026


================
@@ -5764,8 +5764,17 @@ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan, ElementCount VF,
   LLVM_DEBUG(dbgs() << "Cost for VF " << VF << ": " << Cost
                     << " (Estimated cost per lane: ");
   if (Cost.isValid()) {
-    double CostPerLane = double(Cost.getValue()) / EstimatedWidth;
-    LLVM_DEBUG(dbgs() << format("%.1f", CostPerLane));
+    APFloat CostPerLane(APFloat::IEEEdouble(),
----------------
david-arm wrote:

I originally tried that, but if you use convertFromAPInt it requires an extra step, i.e.

```
  APFloat CostPerLane(... initialise to zero ...);
  CostPerLane.convertFromAPInt(...);
```

which seemed inefficient. Happy to do it this way though if the current version is incorrect.

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


More information about the llvm-commits mailing list