[llvm] [RISCV][GISel] Support select G_INSERT_VECTOR_ELT (PR #176687)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 03:02:49 PDT 2026


================
@@ -1374,6 +1374,101 @@ bool RISCVLegalizerInfo::legalizeInsertSubvector(MachineInstr &MI,
   return true;
 }
 
+static std::optional<LLT>
+getSmallestVectorTypeForIndex(LLT VecTy, unsigned MaxIdx,
+                              const RISCVSubtarget &Subtarget) {
+  MVT VecVT = getMVTForLLT(VecTy);
+  assert(VecVT.isScalableVector());
+  const unsigned EltSize = VecVT.getScalarSizeInBits();
+  const unsigned VectorBitsMin = Subtarget.getRealMinVLen();
+  const unsigned MinVLMAX = VectorBitsMin / EltSize;
+  MVT SmallerVT;
+  if (MaxIdx < MinVLMAX)
+    SmallerVT = RISCVTargetLowering::getM1VT(VecVT);
----------------
arsenm wrote:

Probably should add an LLT native equivalent in a follow up 

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


More information about the llvm-commits mailing list