Skip to content

Commit 20becf3

Browse files
authored
[TTI] Move vp.{select,merge} costing from RISCV to BasicTTIImpl. NFC (#147870)
Move the costing to the generic implementation in BasicTTIImpl since it just falls back to the non-vp costing. Also pass through the OperandValueInfo if using value based costing, but I don't believe this affects the result for any in-tree target currently.
1 parent d72d84c commit 20becf3

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,6 +1773,18 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
17731773
}
17741774
}
17751775

1776+
if (ICA.getID() == Intrinsic::vp_select ||
1777+
ICA.getID() == Intrinsic::vp_merge) {
1778+
TTI::OperandValueInfo OpInfoX, OpInfoY;
1779+
if (!ICA.isTypeBasedOnly()) {
1780+
OpInfoX = TTI::getOperandInfo(ICA.getArgs()[0]);
1781+
OpInfoY = TTI::getOperandInfo(ICA.getArgs()[1]);
1782+
}
1783+
return getCmpSelInstrCost(
1784+
Instruction::Select, ICA.getReturnType(), ICA.getArgTypes()[0],
1785+
CmpInst::BAD_ICMP_PREDICATE, CostKind, OpInfoX, OpInfoY);
1786+
}
1787+
17761788
std::optional<Intrinsic::ID> FID =
17771789
VPIntrinsic::getFunctionalIntrinsicIDForVP(ICA.getID());
17781790
if (FID) {

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,17 +1512,6 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
15121512
return Cost * LT.first;
15131513
break;
15141514
}
1515-
case Intrinsic::vp_select: {
1516-
Intrinsic::ID IID = ICA.getID();
1517-
std::optional<unsigned> FOp = VPIntrinsic::getFunctionalOpcodeForVP(IID);
1518-
assert(FOp.has_value());
1519-
return getCmpSelInstrCost(*FOp, ICA.getReturnType(), ICA.getArgTypes()[0],
1520-
CmpInst::BAD_ICMP_PREDICATE, CostKind);
1521-
}
1522-
case Intrinsic::vp_merge:
1523-
return getCmpSelInstrCost(Instruction::Select, ICA.getReturnType(),
1524-
ICA.getArgTypes()[0], CmpInst::BAD_ICMP_PREDICATE,
1525-
CostKind);
15261515
case Intrinsic::experimental_vp_splat: {
15271516
auto LT = getTypeLegalizationCost(RetTy);
15281517
// TODO: Lower i1 experimental_vp_splat

0 commit comments

Comments
 (0)