Skip to content

Commit 558b06d

Browse files
committed
[RISCV][CostModel] Add cost for @llvm.experimental.vp.splice
1 parent a8f3eba commit 558b06d

File tree

2 files changed

+356
-0
lines changed

2 files changed

+356
-0
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,33 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
11891189
: RISCV::VMV_V_X,
11901190
LT.second, CostKind);
11911191
}
1192+
case Intrinsic::experimental_vp_splice: {
1193+
auto LT = getTypeLegalizationCost(RetTy);
1194+
SmallVector<unsigned, 3> Opcodes;
1195+
Value *ImmValue = *(ICA.getInst()->arg_begin() + 2);
1196+
auto *Imm = dyn_cast<ConstantInt>(ImmValue);
1197+
if (Imm->isNegative())
1198+
Opcodes = {RISCV::VSLIDEDOWN_VI, RISCV::VSLIDEUP_VX};
1199+
else
1200+
Opcodes = {RISCV::VSLIDEDOWN_VX, RISCV::VSLIDEUP_VI};
1201+
1202+
if (!ST->hasVInstructions())
1203+
return InstructionCost::getInvalid();
1204+
1205+
if (LT.second.getScalarType() == MVT::i1) {
1206+
SmallVector<unsigned, 8> AddOpcodes = {
1207+
RISCV::VMV1R_V, RISCV::VMV1R_V, RISCV::VMV_V_I, RISCV::VMERGE_VIM,
1208+
RISCV::VMV_V_I, RISCV::VMV1R_V, RISCV::VMERGE_VIM, RISCV::VMSNE_VI};
1209+
return LT.first *
1210+
(getRISCVInstructionCost(Opcodes, LT.second, CostKind) +
1211+
getRISCVInstructionCost(AddOpcodes, LT.second, CostKind)) +
1212+
1;
1213+
} else {
1214+
return LT.first * getRISCVInstructionCost(Opcodes, LT.second, CostKind) +
1215+
1;
1216+
}
1217+
break;
1218+
}
11921219
}
11931220

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

0 commit comments

Comments
 (0)