[llvm] [Support] Always scale InstructionCost::Value (PR #178962)
Ryan Buchner via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 10 00:47:01 PDT 2026
================
@@ -11,14 +11,21 @@
/// instructions.
//===----------------------------------------------------------------------===//
+#include "llvm/Support/Format.h"
#include "llvm/Support/InstructionCost.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
void InstructionCost::print(raw_ostream &OS) const {
- if (isValid())
- OS << Value;
- else
+ if (isValid()) {
+ if (Value % CostGranularity) {
+ double DecimalValue = static_cast<double>(Value) / CostGranularity;
+ OS << format("%.2f", DecimalValue) << " (" << Value << "/" << CostGranularity << ")";
----------------
bababuck wrote:
I had left it to make the denominator explicit to the user, but I think its reasonable to remove given the current decimal result is exact.
https://github.com/llvm/llvm-project/pull/178962
More information about the llvm-commits
mailing list