Skip to content

Commit dd7aabf

Browse files
authored
[TTI][RISCV] Deduplicate type-based VP costing of vpcmp/vpcast (#117520)
Refered to: #115983
1 parent bf07a56 commit dd7aabf

File tree

2 files changed

+15
-33
lines changed

2 files changed

+15
-33
lines changed

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,21 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
16321632
return thisT()->getArithmeticInstrCost(*FOp, ICA.getReturnType(),
16331633
CostKind);
16341634
}
1635+
if (VPCastIntrinsic::isVPCast(ICA.getID())) {
1636+
return thisT()->getCastInstrCost(
1637+
*FOp, ICA.getReturnType(), ICA.getArgTypes()[0],
1638+
TTI::CastContextHint::None, CostKind);
1639+
}
1640+
if (VPCmpIntrinsic::isVPCmp(ICA.getID())) {
1641+
// We can only handle vp_cmp intrinsics with underlying instructions.
1642+
if (ICA.getInst()) {
1643+
assert(FOp);
1644+
auto *UI = cast<VPCmpIntrinsic>(ICA.getInst());
1645+
return thisT()->getCmpSelInstrCost(*FOp, ICA.getArgTypes()[0],
1646+
ICA.getReturnType(),
1647+
UI->getPredicate(), CostKind);
1648+
}
1649+
}
16351650
}
16361651

16371652
std::optional<Intrinsic::ID> FID =

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,39 +1115,6 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
11151115
return getArithmeticInstrCost(*FOp, ICA.getReturnType(), CostKind);
11161116
break;
11171117
}
1118-
// vp int cast ops.
1119-
case Intrinsic::vp_trunc:
1120-
case Intrinsic::vp_zext:
1121-
case Intrinsic::vp_sext:
1122-
// vp float cast ops.
1123-
case Intrinsic::vp_fptoui:
1124-
case Intrinsic::vp_fptosi:
1125-
case Intrinsic::vp_uitofp:
1126-
case Intrinsic::vp_sitofp:
1127-
case Intrinsic::vp_fptrunc:
1128-
case Intrinsic::vp_fpext: {
1129-
std::optional<unsigned> FOp =
1130-
VPIntrinsic::getFunctionalOpcodeForVP(ICA.getID());
1131-
assert(FOp.has_value() && !ICA.getArgTypes().empty());
1132-
return getCastInstrCost(*FOp, RetTy, ICA.getArgTypes()[0],
1133-
TTI::CastContextHint::None, CostKind);
1134-
break;
1135-
}
1136-
1137-
// vp compare
1138-
case Intrinsic::vp_icmp:
1139-
case Intrinsic::vp_fcmp: {
1140-
Intrinsic::ID IID = ICA.getID();
1141-
std::optional<unsigned> FOp = VPIntrinsic::getFunctionalOpcodeForVP(IID);
1142-
// We can only handle vp_cmp intrinsics with underlying instructions.
1143-
if (!ICA.getInst())
1144-
break;
1145-
1146-
assert(FOp);
1147-
auto *UI = cast<VPCmpIntrinsic>(ICA.getInst());
1148-
return getCmpSelInstrCost(*FOp, ICA.getArgTypes()[0], ICA.getReturnType(),
1149-
UI->getPredicate(), CostKind);
1150-
}
11511118
case Intrinsic::vp_select: {
11521119
Intrinsic::ID IID = ICA.getID();
11531120
std::optional<unsigned> FOp = VPIntrinsic::getFunctionalOpcodeForVP(IID);

0 commit comments

Comments
 (0)