[llvm] [RISCV] Don't cost vector arithmetic fp ops as cheaper than scalar (PR #99594)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 09:34:08 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())
----------------
preames wrote:
Mostly stylistic, but I think we should sink this inside getRISCVInstructionCost (probably the default case in the switch), and key this off the legalized type (i.e. LT.second). I don't think this would currently cause any behavior difference, but we could reasonable add another caller of getRISCVInstructionCost which wants this behavior in the future.
https://github.com/llvm/llvm-project/pull/99594
More information about the llvm-commits
mailing list