[llvm] [TTI][RISCV] Deduplicate type-based VP costing of vmcp/vcast (PR #117520)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 24 21:50:50 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
Author: LiqinWeng (LiqinWeng)
<details>
<summary>Changes</summary>
Refered to: https://github.com/llvm/llvm-project/pull/115983
---
Full diff: https://github.com/llvm/llvm-project/pull/117520.diff
2 Files Affected:
- (modified) llvm/include/llvm/CodeGen/BasicTTIImpl.h (+15)
- (modified) llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp (+34-33)
``````````diff
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index d3d68ff1c6ed2b..c226e414d193b5 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -1618,6 +1618,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 45576d515112dd..d82f9c120e81c4 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -1113,39 +1113,40 @@ 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);
- }
+ // // 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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/117520
More information about the llvm-commits
mailing list