[llvm] [RISCV][TTI] Add instruction cost for vp.select. (PR #109381)
Elvis Wang via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 20 06:58:08 PDT 2024
================
@@ -1065,6 +1065,13 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
*FOp, ICA.getArgTypes()[0], UI->getPointerAlignment(),
UI->getOperand(1)->getType()->getPointerAddressSpace(), CostKind);
}
+ case Intrinsic::vp_select: {
+ Intrinsic::ID IID = ICA.getID();
+ std::optional<unsigned> FOp = VPIntrinsic::getFunctionalOpcodeForVP(IID);
+ assert(FOp.has_value());
----------------
ElvisWang123 wrote:
The `VPIntrinsic::getFunctionalOpcodeForVP()` will return an optional with value when the VPIntrinsic has corresponding instruction opcode.
We can find the mapping table in the `llvm/include/llvm/IR/VPIntrinsics.def` which contains a macro called `VP_PROPERTY_FUNCTIONAL_OPC`.
Any query of the opcode for VPIntrinsics with `VP_PROPERTY_FUNCTIONAL_OPC` will not return `std::nullopt`. [Source](https://llvm.org/doxygen/IntrinsicInst_8cpp_source.html#l00519)
In this case, the vp_select contains the `VP_PROPERTY_FUNCTIONAL_OPC(Select)` attribute so we can assert that the `FOp` has value. [Source](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/VPIntrinsics.def#L720C1-L720C27)
https://github.com/llvm/llvm-project/pull/109381
More information about the llvm-commits
mailing list