[llvm] [SelectionDAG] Replace `INSERT_SUBVECTOR` with series of `INSERT_VECTOR_ELT` (PR #124420)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 25 15:49:44 PST 2025


================
@@ -7070,8 +7073,23 @@ SDValue DAGTypeLegalizer::WidenVecOp_INSERT_SUBVECTOR(SDNode *N) {
     return DAG.getNode(ISD::INSERT_SUBVECTOR, SDLoc(N), VT, InVec, SubVec,
                        N->getOperand(2));
 
-  report_fatal_error("Don't know how to widen the operands for "
-                     "INSERT_SUBVECTOR");
+  // If the operands can't be widened legally, just replace the INSERT_SUBVECTOR
+  // with a series of INSERT_VECTOR_ELT
+  EVT OrigVT = OrigSubVec.getValueType();
+  unsigned Idx = N->getConstantOperandVal(2);
+
+  SDValue InsertVecElt;
+  SDLoc DL(N);
+  for (unsigned I = 0; I < OrigVT.getVectorNumElements(); ++I) {
+    SDValue Extract =
+        DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, VT.getScalarType(), SubVec,
+                    DAG.getIntPtrConstant(I, DL, /*isTarget*/ true));
----------------
arsenm wrote:

This should use getVectorIdxTy, not getPointerTy 

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


More information about the llvm-commits mailing list