Skip to content

Commit 15fadeb

Browse files
lukel97arcbbb
andauthored
[RISCV] Add cost for @llvm.experimental.vp.splat (#117313)
This is split off from #115274. There doesn't seem to be an easy way to share this with getShuffleCost since that requires passing in a real insert_element operand to get it to recognise it's a scalar splat. For i1 vectors we can't currently lower them so it returns an invalid cost. --------- Co-authored-by: Shih-Po Hung <[email protected]>
1 parent f81f47e commit 15fadeb

File tree

2 files changed

+238
-2
lines changed

2 files changed

+238
-2
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,16 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
11591159
return getCmpSelInstrCost(Instruction::Select, ICA.getReturnType(),
11601160
ICA.getArgTypes()[0], CmpInst::BAD_ICMP_PREDICATE,
11611161
CostKind);
1162+
case Intrinsic::experimental_vp_splat: {
1163+
auto LT = getTypeLegalizationCost(RetTy);
1164+
// TODO: Lower i1 experimental_vp_splat
1165+
if (!ST->hasVInstructions() || LT.second.getScalarType() == MVT::i1)
1166+
return InstructionCost::getInvalid();
1167+
return LT.first * getRISCVInstructionCost(LT.second.isFloatingPoint()
1168+
? RISCV::VFMV_V_F
1169+
: RISCV::VMV_V_X,
1170+
LT.second, CostKind);
1171+
}
11621172
case Intrinsic::vp_reduce_add:
11631173
case Intrinsic::vp_reduce_fadd:
11641174
case Intrinsic::vp_reduce_mul:

0 commit comments

Comments
 (0)