[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
Fri Apr 25 07:35:19 PDT 2025


================
@@ -9705,6 +9712,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;
----------------
preames wrote:

VL is always going to be <= VLMAX, not the other way around.  But yes, you're correct that we can set TA in all cases here.  I'll do that before landing.

https://github.com/llvm/llvm-project/pull/136708


More information about the llvm-commits mailing list