-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[TTI][RISCV] Deduplicate type-based VP costing of vpcmp/vpcast #117520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-backend-risc-v Author: LiqinWeng (LiqinWeng) ChangesRefered to: #115983 Full diff: https://github.com/llvm/llvm-project/pull/117520.diff 2 Files Affected:
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);
|
96ebd2b
to
8b7c070
Compare
8b7c070
to
4738b83
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks. I think this will also fix the costing of llvm.vp.ptrtoint and llvm.vp.inttoptr. Would you mind adding some tests for these too?
Refered to: #115983