[llvm] [RISCV] Add codegen support for ri.vinsert.v.x and ri.vextract.x.v (PR #136708)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 24 09:55:41 PDT 2025
================
@@ -9686,6 +9693,26 @@ SDValue RISCVTargetLowering::lowerINSERT_VECTOR_ELT(SDValue Op,
return Vec;
return convertFromScalableVector(VecVT, Vec, DAG, Subtarget);
}
+
+ // Use ri.vinsert.v.x if available.
+ if (Subtarget.hasVendorXRivosVisni() && VecVT.isInteger() &&
+ isValidVisniInsertExtractIndex(Idx)) {
+ unsigned Policy = RISCVVType::TAIL_UNDISTURBED_MASK_UNDISTURBED;
+ if (VecVT.isFixedLengthVector() && isa<ConstantSDNode>(Idx) &&
+ Idx->getAsZExtVal() + 1 == VecVT.getVectorNumElements())
+ Policy = RISCVVType::TAIL_AGNOSTIC;
+ SDValue PolicyOp =
+ DAG.getTargetConstant(Policy, DL, Subtarget.getXLenVT());
+ Vec = DAG.getNode(RISCVISD::RI_VINSERT_VL, DL, ContainerVT, Vec, Val, Idx,
----------------
preames wrote:
> We should change Idx to a TargetConstant here and use tuimm6 in the isel patterns.
I tried this, and got some very opaque build errors of the form:
```
In file included from ../llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp:36:
lib/Target/RISCV/RISCVGenInstrInfo.inc:33846:144: error: ‘OPERAND_UNKNOWN’ is not a member of ‘llvm::RISCVOp’; did you mean ‘llvm::MCOI::OPERAND_UNKNOWN’?
33846 | /* 353 */ { RISCV::GPRRegClassID, 0, MCOI::OPERAND_REGISTER, 0 }, { RISCV::VRRegClassID, 0, MCOI::OPERAND_REGISTER, 0 }, { -1, 0, RISCVOp::OPERAND_UNKNOWN, 0 }, { -1, 0, MCOI::OPERAND_UNKNOWN, 0 },
```
https://github.com/llvm/llvm-project/pull/136708
More information about the llvm-commits
mailing list