Skip to content

Commit 4762f3b

Browse files
authored
[RISCV][TTI] Add cost of type based binOp VP intrinsics with functionalOPC. (#93435)
Intrinsics not supported in the backend will fall Into BasicTTIImpl, which will check if the VP intrinsic is a type based instruction. All type based instruction will fall into the `getTypeBasedIntrinsicInstrCost()` which doesn't support instruction with scalable vector type. This patch adds the instruction cost for type based binOp VP intrinsic instructions in the backend to get the valid instruction costs. The cost of type based binOp VP intrinsics will be same as their non-VP counterpart.
1 parent 839ed1b commit 4762f3b

File tree

3 files changed

+1088
-220
lines changed

3 files changed

+1088
-220
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,32 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
959959
return Cost * LT.first;
960960
break;
961961
}
962+
// vp integer arithmetic ops.
963+
case Intrinsic::vp_add:
964+
case Intrinsic::vp_and:
965+
case Intrinsic::vp_ashr:
966+
case Intrinsic::vp_lshr:
967+
case Intrinsic::vp_mul:
968+
case Intrinsic::vp_or:
969+
case Intrinsic::vp_sdiv:
970+
case Intrinsic::vp_shl:
971+
case Intrinsic::vp_srem:
972+
case Intrinsic::vp_sub:
973+
case Intrinsic::vp_udiv:
974+
case Intrinsic::vp_urem:
975+
case Intrinsic::vp_xor:
976+
// vp float arithmetic ops.
977+
case Intrinsic::vp_fadd:
978+
case Intrinsic::vp_fsub:
979+
case Intrinsic::vp_fmul:
980+
case Intrinsic::vp_fdiv:
981+
case Intrinsic::vp_frem: {
982+
std::optional<unsigned> FOp =
983+
VPIntrinsic::getFunctionalOpcodeForVP(ICA.getID());
984+
if (FOp)
985+
return getArithmeticInstrCost(*FOp, ICA.getReturnType(), CostKind);
986+
break;
987+
}
962988
}
963989

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

0 commit comments

Comments
 (0)