[llvm] [RISCV][CostModel] Estimate cost of llvm.vector.reduce.fmaximum/fminimum (PR #80697)
Shih-Po Hung via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 20 10:55:27 PDT 2024
================
@@ -1001,6 +1001,53 @@ RISCVTTIImpl::getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty,
return getArithmeticReductionCost(Instruction::And, Ty, FMF, CostKind);
}
+ if (IID == Intrinsic::maximum || IID == Intrinsic::minimum) {
+ SmallVector<unsigned, 5> SplitOps;
+ SmallVector<unsigned, 3> Opcodes;
+ InstructionCost ExtraCost = 0;
+ switch (IID) {
+ case Intrinsic::maximum:
+ if (FMF.noNaNs()) {
+ SplitOps = {RISCV::VFMAX_VV};
+ Opcodes = {RISCV::VFREDMAX_VS, RISCV::VFMV_F_S};
+ } else {
+ SplitOps = {RISCV::VMFEQ_VV, RISCV::VMERGE_VVM, RISCV::VMFEQ_VV,
+ RISCV::VMERGE_VVM, RISCV::VFMAX_VV};
+ Opcodes = {RISCV::VMFNE_VV, RISCV::VCPOP_M, RISCV::VFREDMAX_VS,
+ RISCV::VFMV_F_S};
+ // Cost of Canonical Nan
+ // lui a0, 523264
+ // fmv.w.x fa0, a0
+ ExtraCost = 2;
----------------
arcbbb wrote:
Fixed with getCastInstrCost.
https://github.com/llvm/llvm-project/pull/80697
More information about the llvm-commits
mailing list