[llvm] [RISCV][CostModel] Add cost for fabs/fsqrt of type bf16/f16 (PR #118608)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 26 18:45:51 PST 2024
================
@@ -1060,15 +1060,28 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
auto NVT = LT.second;
if (ST->hasVInstructions() && LT.second.isVector()) {
SmallVector<unsigned, 3> Opcodes;
- // f16 with zvfhmin and bf16 with zvfbfmin
+ // f16 with zvfhmin and bf16 with zvfbfmin and the type of nxv32[b]f16
+ // will be spilt.
if (LT.second.getVectorElementType() == MVT::bf16) {
- Opcodes = {RISCV::VFWCVTBF16_F_F_V, RISCV::VFSQRT_V,
- RISCV::VFNCVTBF16_F_F_W};
- NVT = TLI->getTypeToPromoteTo(ISD::FSQRT, NVT);
+ if (LT.second == MVT::nxv32bf16) {
+ Opcodes = {RISCV::VFWCVTBF16_F_F_V, RISCV::VFWCVTBF16_F_F_V,
+ RISCV::VFSQRT_V, RISCV::VFSQRT_V,
+ RISCV::VFNCVTBF16_F_F_W, RISCV::VFNCVTBF16_F_F_W};
+ } else {
+ Opcodes = {RISCV::VFWCVTBF16_F_F_V, RISCV::VFSQRT_V,
+ RISCV::VFNCVTBF16_F_F_W};
+ NVT = TLI->getTypeToPromoteTo(ISD::FSQRT, NVT);
+ }
} else if (LT.second.getVectorElementType() == MVT::f16 &&
!ST->hasVInstructionsF16()) {
- Opcodes = {RISCV::VFWCVT_F_F_V, RISCV::VFSQRT_V, RISCV::VFNCVT_F_F_W};
- NVT = TLI->getTypeToPromoteTo(ISD::FSQRT, NVT);
+ if (LT.second == MVT::nxv32f16) {
+ Opcodes = {RISCV::VFWCVT_F_F_V, RISCV::VFWCVT_F_F_V,
+ RISCV::VFSQRT_V, RISCV::VFSQRT_V,
----------------
topperc wrote:
NVT needs to be changed to v16f32.
https://github.com/llvm/llvm-project/pull/118608
More information about the llvm-commits
mailing list