[llvm] [TTI][RISCV] Deduplicate type-based VP costing of VPReduction (PR #117708)
Elvis Wang via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 27 23:26:09 PST 2024
================
@@ -1647,6 +1647,38 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
UI->getPredicate(), CostKind);
}
}
+ if (VPReductionIntrinsic::isVPReduction(ICA.getID())) {
+ std::optional<Intrinsic::ID> RedID =
+ VPIntrinsic::getFunctionalIntrinsicIDForVP(ICA.getID());
+ assert(RedID.has_value());
+ switch (ICA.getID()) {
+ 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: {
+ unsigned RedOp = getArithmeticReductionInstruction(*RedID);
+ return thisT()->getArithmeticReductionCost(
+ RedOp, cast<VectorType>(ICA.getArgTypes()[1]), ICA.getFlags(),
----------------
ElvisWang123 wrote:
You can find that the type-based vp reductions were supported in #115983. [link](https://github.com/llvm/llvm-project/blob/93f7398bdba9d1547df21156db4d5393f0ab5ec8/llvm/include/llvm/CodeGen/BasicTTIImpl.h#L1665)
I think you only need to remove `vp_reduce_*` in the RISCVTTI.
https://github.com/llvm/llvm-project/pull/117708
More information about the llvm-commits
mailing list