[llvm] [RISCV] Don't cost vector arithmetic fp ops as cheaper than scalar (PR #99594)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 09:51:46 PDT 2024
================
@@ -1739,8 +1738,14 @@ InstructionCost RISCVTTIImpl::getArithmeticInstrCost(
Op1Info, Op2Info,
Args, CxtI);
}
- return ConstantMatCost +
- LT.first * getRISCVInstructionCost(Op, LT.second, CostKind);
+
+ InstructionCost InstrCost = getRISCVInstructionCost(Op, LT.second, CostKind);
+ // We use BasicTTIImpl to calculate scalar costs, which assumes floating point
+ // ops are twice as expensive as integer ops. Do the same for vectors so
+ // scalar floating point ops aren't cheaper than their vector equivalents.
+ if (Ty->isFPOrFPVectorTy())
----------------
lukel97 wrote:
That's what I did at first, but after grepping I found other non-arithmetic FP users of getRISCVInstructionCost like VFMV_V_F which had some observable cost model differences.
BasicTTIImpl only seems to double the cost for floats in getArithmeticInstrCost, so I wanted to keep it local to RISCVTTIImpl::getArithmeticInstrCost since that's the only place where we need the fp-cost-doubling to stay in sync with scalar costs
https://github.com/llvm/llvm-project/pull/99594
More information about the llvm-commits
mailing list