Skip to content

Commit da8d7f4

Browse files
authored
[RISCV] Unify non-vp and vp rounding intrinsic costing (#147872)
Currently we have slightly different costing for the vp and non-vp version of the rounding intrinsics. We can delete this code and use the generic BasicTTIImpl code for the vp intrinsics which falls back to the non-vp versions. I'm not sure if the zvfh costing is correct, this should probably be fixed in a follow up patch. At the moment the non-vp cost is more important since it is what the loop vectorizer will use.
1 parent 60c14ac commit da8d7f4

File tree

2 files changed

+165
-206
lines changed

2 files changed

+165
-206
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,17 +1244,6 @@ static const CostTblEntry VectorIntrinsicCostTable[]{
12441244
{Intrinsic::vp_cttz, MVT::i64, 25},
12451245
};
12461246

1247-
static unsigned getISDForVPIntrinsicID(Intrinsic::ID ID) {
1248-
switch (ID) {
1249-
#define HELPER_MAP_VPID_TO_VPSD(VPID, VPSD) \
1250-
case Intrinsic::VPID: \
1251-
return ISD::VPSD;
1252-
#include "llvm/IR/VPIntrinsics.def"
1253-
#undef HELPER_MAP_VPID_TO_VPSD
1254-
}
1255-
return ISD::DELETED_NODE;
1256-
}
1257-
12581247
InstructionCost
12591248
RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
12601249
TTI::TargetCostKind CostKind) const {
@@ -1482,36 +1471,6 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
14821471

14831472
return Cost;
14841473
}
1485-
case Intrinsic::vp_rint: {
1486-
// RISC-V target uses at least 5 instructions to lower rounding intrinsics.
1487-
unsigned Cost = 5;
1488-
auto LT = getTypeLegalizationCost(RetTy);
1489-
if (TLI->isOperationCustom(ISD::VP_FRINT, LT.second))
1490-
return Cost * LT.first;
1491-
break;
1492-
}
1493-
case Intrinsic::vp_nearbyint: {
1494-
// More one read and one write for fflags than vp_rint.
1495-
unsigned Cost = 7;
1496-
auto LT = getTypeLegalizationCost(RetTy);
1497-
if (TLI->isOperationCustom(ISD::VP_FRINT, LT.second))
1498-
return Cost * LT.first;
1499-
break;
1500-
}
1501-
case Intrinsic::vp_ceil:
1502-
case Intrinsic::vp_floor:
1503-
case Intrinsic::vp_round:
1504-
case Intrinsic::vp_roundeven:
1505-
case Intrinsic::vp_roundtozero: {
1506-
// Rounding with static rounding mode needs two more instructions to
1507-
// swap/write FRM than vp_rint.
1508-
unsigned Cost = 7;
1509-
auto LT = getTypeLegalizationCost(RetTy);
1510-
unsigned VPISD = getISDForVPIntrinsicID(ICA.getID());
1511-
if (TLI->isOperationCustom(VPISD, LT.second))
1512-
return Cost * LT.first;
1513-
break;
1514-
}
15151474
case Intrinsic::experimental_vp_splat: {
15161475
auto LT = getTypeLegalizationCost(RetTy);
15171476
// TODO: Lower i1 experimental_vp_splat

0 commit comments

Comments
 (0)