[llvm] [TTI][RISCV] Deduplicate type-based VP costing (PR #115983)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 12 22:12:07 PST 2024
================
@@ -1563,6 +1563,67 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
if (Intrinsic::isTargetIntrinsic(IID))
return TargetTransformInfo::TCC_Basic;
+ // VP Intrinsics should have the same cost as their non-vp counterpart.
+ // TODO: Adjust the cost to make the vp intrinsic cheaper than its non-vp
+ // counterpart when the vector length argument is smaller than the maximum
+ // vector length.
+ // TODO: Support other kinds of VPIntrinsics
+ if (VPIntrinsic::isVPIntrinsic(ICA.getID())) {
+ std::optional<unsigned> FOp =
+ VPIntrinsic::getFunctionalOpcodeForVP(ICA.getID());
+ if (FOp) {
+ if (ICA.getID() == Intrinsic::vp_load) {
+ Align Alignment;
+ if (auto *VPI = dyn_cast_or_null<VPIntrinsic>(ICA.getInst()))
+ Alignment = VPI->getPointerAlignment().valueOrOne();
+ unsigned AS = 0;
+ if (ICA.getArgTypes().size() > 1)
+ if (auto *PtrTy = dyn_cast<PointerType>(ICA.getArgTypes()[0]))
+ AS = PtrTy->getAddressSpace();
+ return thisT()->getMemoryOpCost(*FOp, ICA.getReturnType(), Alignment,
+ AS, CostKind);
+ }
+ if (ICA.getID() == Intrinsic::vp_store) {
+ Align Alignment;
+ if (auto *VPI = dyn_cast_or_null<VPIntrinsic>(ICA.getInst()))
+ Alignment = VPI->getPointerAlignment().valueOrOne();
+ unsigned AS = 0;
+ if (ICA.getArgTypes().size() >= 2)
+ if (auto *PtrTy = dyn_cast<PointerType>(ICA.getArgTypes()[1]))
+ AS = PtrTy->getAddressSpace();
+ return thisT()->getMemoryOpCost(*FOp, ICA.getArgTypes()[0], Alignment,
+ AS, CostKind);
----------------
lukel97 wrote:
Good point. This is from the existing code though so the non type-based cost would have been incorrect anyway
https://github.com/llvm/llvm-project/pull/115983
More information about the llvm-commits
mailing list