Skip to content

Commit

Permalink
[RISCV][TTI] Add cost of type based binOp VP intrinsics with function…
Browse files Browse the repository at this point in the history
…alOPC. (#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.
  • Loading branch information
ElvisWang123 authored Jul 5, 2024
1 parent 839ed1b commit 4762f3b
Show file tree
Hide file tree
Showing 3 changed files with 1,088 additions and 220 deletions.
26 changes: 26 additions & 0 deletions llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,32 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
return Cost * LT.first;
break;
}
// vp integer arithmetic ops.
case Intrinsic::vp_add:
case Intrinsic::vp_and:
case Intrinsic::vp_ashr:
case Intrinsic::vp_lshr:
case Intrinsic::vp_mul:
case Intrinsic::vp_or:
case Intrinsic::vp_sdiv:
case Intrinsic::vp_shl:
case Intrinsic::vp_srem:
case Intrinsic::vp_sub:
case Intrinsic::vp_udiv:
case Intrinsic::vp_urem:
case Intrinsic::vp_xor:
// vp float arithmetic ops.
case Intrinsic::vp_fadd:
case Intrinsic::vp_fsub:
case Intrinsic::vp_fmul:
case Intrinsic::vp_fdiv:
case Intrinsic::vp_frem: {
std::optional<unsigned> FOp =
VPIntrinsic::getFunctionalOpcodeForVP(ICA.getID());
if (FOp)
return getArithmeticInstrCost(*FOp, ICA.getReturnType(), CostKind);
break;
}
}

if (ST->hasVInstructions() && RetTy->isVectorTy()) {
Expand Down
Loading

0 comments on commit 4762f3b

Please sign in to comment.