[llvm] [TTI][RISCV] Deduplicate type-based VP costing of vpReduction (PR #117708)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 26 04:26:57 PST 2024
https://github.com/LiqinWeng created https://github.com/llvm/llvm-project/pull/117708
Refered to: #115983
>From 08a62018a7afbcfcf49916a93f4e80f0c3121fc2 Mon Sep 17 00:00:00 2001
From: LiqinWeng <liqin.weng at spacemit.com>
Date: Tue, 26 Nov 2024 20:24:51 +0800
Subject: [PATCH] [TTI][RISCV] Deduplicate type-based VP costing of vpReduction
Refered to: #115983
---
llvm/include/llvm/CodeGen/BasicTTIImpl.h | 32 +++++++++++++++++++
.../Target/RISCV/RISCVTargetTransformInfo.cpp | 31 ------------------
2 files changed, 32 insertions(+), 31 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index 98cbb4886642bf..21c1f98c78fe7c 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -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(),
+ CostKind);
+ }
+ case Intrinsic::vp_reduce_smax:
+ case Intrinsic::vp_reduce_smin:
+ case Intrinsic::vp_reduce_umax:
+ case Intrinsic::vp_reduce_umin:
+ case Intrinsic::vp_reduce_fmax:
+ case Intrinsic::vp_reduce_fmaximum:
+ case Intrinsic::vp_reduce_fmin:
+ case Intrinsic::vp_reduce_fminimum: {
+ Intrinsic::ID MinMaxID = getMinMaxReductionIntrinsicOp(*RedID);
+ return thisT()->getMinMaxReductionCost(
+ MinMaxID, cast<VectorType>(ICA.getArgTypes()[1]),
+ ICA.getFlags(), CostKind);
+ }
+ }
+ }
}
std::optional<Intrinsic::ID> FID =
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 8f0ef69258b165..bbded57bb92ab0 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -1144,37 +1144,6 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
: RISCV::VMV_V_X,
LT.second, 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);
- return getArithmeticReductionCost(RedOp,
- cast<VectorType>(ICA.getArgTypes()[1]),
- ICA.getFlags(), CostKind);
- }
- case Intrinsic::vp_reduce_smax:
- case Intrinsic::vp_reduce_smin:
- case Intrinsic::vp_reduce_umax:
- case Intrinsic::vp_reduce_umin:
- case Intrinsic::vp_reduce_fmax:
- case Intrinsic::vp_reduce_fmaximum:
- case Intrinsic::vp_reduce_fmin:
- case Intrinsic::vp_reduce_fminimum: {
- std::optional<Intrinsic::ID> RedID =
- VPIntrinsic::getFunctionalIntrinsicIDForVP(ICA.getID());
- assert(RedID.has_value());
- Intrinsic::ID MinMaxID = getMinMaxReductionIntrinsicOp(*RedID);
- return getMinMaxReductionCost(MinMaxID,
- cast<VectorType>(ICA.getArgTypes()[1]),
- ICA.getFlags(), CostKind);
- }
}
if (ST->hasVInstructions() && RetTy->isVectorTy()) {
More information about the llvm-commits
mailing list