Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, 3> Opcodes;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3->2. The are only 2 opcodes in your lists.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Value *ImmValue = *(ICA.getInst()->arg_begin() + 2);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getInst()->getArgOperand(2)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

auto *Imm = dyn_cast<ConstantInt>(ImmValue);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use dyn_cast, you must check the result for null before dereferencing. If can't be null, use cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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) {
SmallVector<unsigned, 8> AddOpcodes = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use a normal C array here. It doesn't need to be a SmallVector.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No else if the if body returns.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

return LT.first * getRISCVInstructionCost(Opcodes, LT.second, CostKind) +
1;
}
break;
}
}

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