[llvm] [SelectionDAG] WidenVecOp_INSERT_SUBVECTOR - Replace `INSERT_SUBVECTOR` with series of `INSERT_VECTOR_ELT` (PR #124420)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 27 06:44:57 PST 2025
================
@@ -7070,8 +7073,24 @@ 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 InsertElt;
+ SDLoc DL(N);
+ EVT VectorIdxTy = TLI.getVectorIdxTy(DAG.getDataLayout());
+ for (unsigned I = 0; I < OrigVT.getVectorNumElements(); ++I) {
+ SDValue ExtractElt =
+ DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, VT.getScalarType(), SubVec,
+ DAG.getConstant(I, DL, VectorIdxTy));
+ InsertElt =
+ DAG.getNode(ISD::INSERT_VECTOR_ELT, DL, VT, I != 0 ? InsertElt : InVec,
----------------
RKSimon wrote:
Just initialize InsertElt to InVec and remove the `I !=0` handling
https://github.com/llvm/llvm-project/pull/124420
More information about the llvm-commits
mailing list