[llvm] [RISCV][CostModel] Add cost for @llvm.experimental.vp.splice (PR #122223)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 12 11:24:34 PST 2025
================
@@ -1235,6 +1235,33 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
: RISCV::VMV_V_X,
LT.second, CostKind);
}
+ case Intrinsic::experimental_vp_splice: {
+ auto LT = getTypeLegalizationCost(RetTy);
+ SmallVector<unsigned, 2> Opcodes;
+ Value *ImmValue = *(ICA.getInst()->arg_begin() + 2);
+ auto *Imm = cast<ConstantInt>(ImmValue);
+ if (Imm->isNegative())
+ Opcodes = {RISCV::VSLIDEDOWN_VI, RISCV::VSLIDEUP_VX};
+ else
+ Opcodes = {RISCV::VSLIDEDOWN_VX, RISCV::VSLIDEUP_VI};
+
+ if (!ST->hasVInstructions())
+ return InstructionCost::getInvalid();
+
+ if (LT.second.getScalarType() == MVT::i1) {
+ unsigned AddOpcodes[8] = {
+ RISCV::VMV1R_V, RISCV::VMV1R_V, RISCV::VMV_V_I, RISCV::VMERGE_VIM,
+ RISCV::VMV_V_I, RISCV::VMV1R_V, RISCV::VMERGE_VIM, RISCV::VMSNE_VI};
+ return LT.first *
+ (getRISCVInstructionCost(Opcodes, LT.second, CostKind) +
+ getRISCVInstructionCost(AddOpcodes, LT.second, CostKind)) +
+ 1;
+ } else {
----------------
topperc wrote:
No `else` if the `if` body returns.
https://github.com/llvm/llvm-project/pull/122223
More information about the llvm-commits
mailing list