[llvm] [RISCV][TTI] Implement instruction cost for vp.reduce.* (PR #114184)
Elvis Wang via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 6 21:40:55 PST 2024
================
@@ -1191,6 +1191,40 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
return getCmpSelInstrCost(Instruction::Select, ICA.getReturnType(),
ICA.getArgTypes()[0], CmpInst::BAD_ICMP_PREDICATE,
CostKind);
+ case Intrinsic::vp_reduce_add:
+ case Intrinsic::vp_reduce_fadd:
+ case Intrinsic::vp_reduce_mul:
+ case Intrinsic::vp_reduce_fmul:
+ case Intrinsic::vp_reduce_and:
+ case Intrinsic::vp_reduce_or:
+ case Intrinsic::vp_reduce_xor: {
+ std::optional<Intrinsic::ID> RedID =
+ VPIntrinsic::getFunctionalIntrinsicIDForVP(ICA.getID());
+ assert(RedID.has_value());
+ unsigned RedOp = getArithmeticReductionInstruction(*RedID);
+ if (RedOp == Instruction::FAdd || RedOp == Instruction::FMul)
+ return getArithmeticReductionCost(RedOp,
+ cast<VectorType>(ICA.getArgTypes()[1]),
+ ICA.getFlags(), CostKind);
+ return getArithmeticReductionCost(
+ RedOp, cast<VectorType>(ICA.getArgTypes()[1]), std::nullopt, CostKind);
----------------
ElvisWang123 wrote:
Fixed.
Before #114180 landed , passing FMF flags into `getArightmeicReductionCost()` with int reductions will always return the cost of `oredered fadd reduction`.
https://github.com/llvm/llvm-project/pull/114184
More information about the llvm-commits
mailing list