[llvm] dd7aabf - [TTI][RISCV] Deduplicate type-based VP costing of vpcmp/vpcast (#117520)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 25 18:49:28 PST 2024
Author: LiqinWeng
Date: 2024-11-26T10:49:24+08:00
New Revision: dd7aabf7c041f094ef2124bb5b8fe9434490d266
URL: https://github.com/llvm/llvm-project/commit/dd7aabf7c041f094ef2124bb5b8fe9434490d266
DIFF: https://github.com/llvm/llvm-project/commit/dd7aabf7c041f094ef2124bb5b8fe9434490d266.diff
LOG: [TTI][RISCV] Deduplicate type-based VP costing of vpcmp/vpcast (#117520)
Refered to: https://github.com/llvm/llvm-project/pull/115983
Added:
Modified:
llvm/include/llvm/CodeGen/BasicTTIImpl.h
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index d2fc40d8ae037e..98cbb4886642bf 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -1632,6 +1632,21 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return thisT()->getArithmeticInstrCost(*FOp, ICA.getReturnType(),
CostKind);
}
+ if (VPCastIntrinsic::isVPCast(ICA.getID())) {
+ return thisT()->getCastInstrCost(
+ *FOp, ICA.getReturnType(), ICA.getArgTypes()[0],
+ TTI::CastContextHint::None, CostKind);
+ }
+ if (VPCmpIntrinsic::isVPCmp(ICA.getID())) {
+ // We can only handle vp_cmp intrinsics with underlying instructions.
+ if (ICA.getInst()) {
+ assert(FOp);
+ auto *UI = cast<VPCmpIntrinsic>(ICA.getInst());
+ return thisT()->getCmpSelInstrCost(*FOp, ICA.getArgTypes()[0],
+ ICA.getReturnType(),
+ UI->getPredicate(), CostKind);
+ }
+ }
}
std::optional<Intrinsic::ID> FID =
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 017264fbd46e01..ee4629edc1303a 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -1115,39 +1115,6 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
return getArithmeticInstrCost(*FOp, ICA.getReturnType(), CostKind);
break;
}
- // vp int cast ops.
- case Intrinsic::vp_trunc:
- case Intrinsic::vp_zext:
- case Intrinsic::vp_sext:
- // vp float cast ops.
- case Intrinsic::vp_fptoui:
- case Intrinsic::vp_fptosi:
- case Intrinsic::vp_uitofp:
- case Intrinsic::vp_sitofp:
- case Intrinsic::vp_fptrunc:
- case Intrinsic::vp_fpext: {
- std::optional<unsigned> FOp =
- VPIntrinsic::getFunctionalOpcodeForVP(ICA.getID());
- assert(FOp.has_value() && !ICA.getArgTypes().empty());
- return getCastInstrCost(*FOp, RetTy, ICA.getArgTypes()[0],
- TTI::CastContextHint::None, CostKind);
- break;
- }
-
- // vp compare
- case Intrinsic::vp_icmp:
- case Intrinsic::vp_fcmp: {
- Intrinsic::ID IID = ICA.getID();
- std::optional<unsigned> FOp = VPIntrinsic::getFunctionalOpcodeForVP(IID);
- // We can only handle vp_cmp intrinsics with underlying instructions.
- if (!ICA.getInst())
- break;
-
- assert(FOp);
- auto *UI = cast<VPCmpIntrinsic>(ICA.getInst());
- return getCmpSelInstrCost(*FOp, ICA.getArgTypes()[0], ICA.getReturnType(),
- UI->getPredicate(), CostKind);
- }
case Intrinsic::vp_select: {
Intrinsic::ID IID = ICA.getID();
std::optional<unsigned> FOp = VPIntrinsic::getFunctionalOpcodeForVP(IID);
More information about the llvm-commits
mailing list