[llvm] [RISCV] Don't cost vector arithmetic fp ops as cheaper than scalar (PR #99594)

Shih-Po Hung via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 23 21:08:18 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())
----------------
arcbbb wrote:

Sorry to be late to see this.
Can we do this to specific FP operations like VFADD_VV, VFMUL_VV, VFDIV_VV instead?
I am trying to introduce a vendor-specific TTI cost in #90951. With this patch getArithmeticInstrCost would double the vendor cost  unexpectedly.

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


More information about the llvm-commits mailing list