Skip to content

Commit 1b3e64a

Browse files
authored
[RISCV][TTI] Add vp.cmp intrinsic cost with functionalOPC. (llvm#107504)
This patch make the instruction cost of VP compare intrinsics as same as their non-VP counterpart.
1 parent 6e4dcbb commit 1b3e64a

File tree

2 files changed

+675
-0
lines changed

2 files changed

+675
-0
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,21 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
10331033
TTI::CastContextHint::None, CostKind);
10341034
break;
10351035
}
1036+
1037+
// vp compare
1038+
case Intrinsic::vp_icmp:
1039+
case Intrinsic::vp_fcmp: {
1040+
Intrinsic::ID IID = ICA.getID();
1041+
std::optional<unsigned> FOp = VPIntrinsic::getFunctionalOpcodeForVP(IID);
1042+
auto *UI = dyn_cast<VPCmpIntrinsic>(ICA.getInst());
1043+
1044+
// We can only handle vp_cmp intrinsics with underlying instructions.
1045+
if (!UI)
1046+
break;
1047+
assert(FOp);
1048+
return getCmpSelInstrCost(*FOp, ICA.getArgTypes()[0], ICA.getReturnType(),
1049+
UI->getPredicate(), CostKind);
1050+
}
10361051
}
10371052

10381053
if (ST->hasVInstructions() && RetTy->isVectorTy()) {

0 commit comments

Comments
 (0)