[llvm] [RISCV][GISel] Support select G_INSERT_SUBVECTOR (PR #171092)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 9 19:36:55 PDT 2026


================
@@ -1102,6 +1102,64 @@ bool RISCVInstructionSelector::selectExtractSubvector(MachineInstr &MI) const {
   return true;
 }
 
+bool RISCVInstructionSelector::selectInsertSubVector(MachineInstr &MI) const {
+  assert(MI.getOpcode() == TargetOpcode::G_INSERT_SUBVECTOR);
+
+  Register DstReg = MI.getOperand(0).getReg();
+  Register VecReg = MI.getOperand(1).getReg();
+  Register SubVecReg = MI.getOperand(2).getReg();
+
+  LLT VecTy = MRI->getType(VecReg);
+  LLT SubVecTy = MRI->getType(SubVecReg);
+
+  MVT VecMVT = getMVTForLLT(VecTy);
+  MVT SubVecMVT = getMVTForLLT(SubVecTy);
+
+  unsigned Idx = static_cast<unsigned>(MI.getOperand(3).getImm());
----------------
topperc wrote:

I think the DAGCombines in SelectionDAG guarantee that it's in range and the DAGCombines can't be disabled. GISel doesn't guarantee any combines are run, especially in O0.

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


More information about the llvm-commits mailing list