[llvm] [RISCV] Add codegen support for ri.vinsert.v.x and ri.vextract.x.v (PR #136708)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 24 09:07:57 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,
----------------
topperc wrote:
We should change Idx to a TargetConstant here and use `tuimm6` in the isel patterns.
We're probably not always consistent about it, but operands we expect to be constants should be TargetConstant.
https://github.com/llvm/llvm-project/pull/136708
More information about the llvm-commits
mailing list