Skip to content

Commit 845d8d9

Browse files
authored
[RISCV][TTI] Add cost of typebased cast VPIntrinsics with functionalOPC. (#97797)
This patch make the instruction cost of type-based cast VP intrinsics will be same as their non-VP counterpart. This is the following patch of [#93435](#93435)
1 parent da8fb7f commit 845d8d9

File tree

2 files changed

+3427
-4
lines changed

2 files changed

+3427
-4
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,8 +1011,26 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
10111011
case Intrinsic::vp_frem: {
10121012
std::optional<unsigned> FOp =
10131013
VPIntrinsic::getFunctionalOpcodeForVP(ICA.getID());
1014-
if (FOp)
1015-
return getArithmeticInstrCost(*FOp, ICA.getReturnType(), CostKind);
1014+
assert(FOp.has_value());
1015+
return getArithmeticInstrCost(*FOp, ICA.getReturnType(), CostKind);
1016+
break;
1017+
}
1018+
// vp int cast ops.
1019+
case Intrinsic::vp_trunc:
1020+
case Intrinsic::vp_zext:
1021+
case Intrinsic::vp_sext:
1022+
// vp float cast ops.
1023+
case Intrinsic::vp_fptoui:
1024+
case Intrinsic::vp_fptosi:
1025+
case Intrinsic::vp_uitofp:
1026+
case Intrinsic::vp_sitofp:
1027+
case Intrinsic::vp_fptrunc:
1028+
case Intrinsic::vp_fpext: {
1029+
std::optional<unsigned> FOp =
1030+
VPIntrinsic::getFunctionalOpcodeForVP(ICA.getID());
1031+
assert(FOp.has_value() && !ICA.getArgTypes().empty());
1032+
return getCastInstrCost(*FOp, RetTy, ICA.getArgTypes()[0],
1033+
TTI::CastContextHint::None, CostKind);
10161034
break;
10171035
}
10181036
}

0 commit comments

Comments
 (0)