@@ -191,6 +191,7 @@ class SelectionDAGLegalize {
191
191
SDValue ExpandExtractFromVectorThroughStack (SDValue Op);
192
192
SDValue ExpandInsertToVectorThroughStack (SDValue Op);
193
193
SDValue ExpandVectorBuildThroughStack (SDNode* Node);
194
+ SDValue ExpandConcatVectors (SDNode *Node);
194
195
195
196
SDValue ExpandConstantFP (ConstantFPSDNode *CFP, bool UseCP);
196
197
SDValue ExpandConstant (ConstantSDNode *CP);
@@ -1517,6 +1518,27 @@ SDValue SelectionDAGLegalize::ExpandInsertToVectorThroughStack(SDValue Op) {
1517
1518
BaseVecAlignment);
1518
1519
}
1519
1520
1521
+ SDValue SelectionDAGLegalize::ExpandConcatVectors (SDNode *Node) {
1522
+ assert (Node->getOpcode () == ISD::CONCAT_VECTORS && " Unexpected opcode!" );
1523
+ SDLoc DL (Node);
1524
+ SmallVector<SDValue, 16 > Ops;
1525
+ unsigned NumOperands = Node->getNumOperands ();
1526
+ MVT VectorIdxType = TLI.getVectorIdxTy (DAG.getDataLayout ());
1527
+ EVT VectorValueType = Node->getOperand (0 ).getValueType ();
1528
+ unsigned NumSubElem = VectorValueType.getVectorNumElements ();
1529
+ EVT ElementValueType = TLI.getTypeToTransformTo (
1530
+ *DAG.getContext (), VectorValueType.getVectorElementType ());
1531
+ for (unsigned I = 0 ; I < NumOperands; ++I) {
1532
+ SDValue SubOp = Node->getOperand (I);
1533
+ for (unsigned Idx = 0 ; Idx < NumSubElem; ++Idx) {
1534
+ Ops.push_back (DAG.getNode (ISD::EXTRACT_VECTOR_ELT, DL, ElementValueType,
1535
+ SubOp,
1536
+ DAG.getConstant (Idx, DL, VectorIdxType)));
1537
+ }
1538
+ }
1539
+ return DAG.getBuildVector (Node->getValueType (0 ), DL, Ops);
1540
+ }
1541
+
1520
1542
SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack (SDNode* Node) {
1521
1543
assert ((Node->getOpcode () == ISD::BUILD_VECTOR ||
1522
1544
Node->getOpcode () == ISD::CONCAT_VECTORS) &&
@@ -3375,7 +3397,12 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
3375
3397
Results.push_back (ExpandInsertToVectorThroughStack (SDValue (Node, 0 )));
3376
3398
break ;
3377
3399
case ISD::CONCAT_VECTORS:
3378
- Results.push_back (ExpandVectorBuildThroughStack (Node));
3400
+ if (EVT VectorValueType = Node->getOperand (0 ).getValueType ();
3401
+ VectorValueType.isScalableVector () ||
3402
+ TLI.isOperationExpand (ISD::EXTRACT_VECTOR_ELT, VectorValueType))
3403
+ Results.push_back (ExpandVectorBuildThroughStack (Node));
3404
+ else
3405
+ Results.push_back (ExpandConcatVectors (Node));
3379
3406
break ;
3380
3407
case ISD::SCALAR_TO_VECTOR:
3381
3408
Results.push_back (ExpandSCALAR_TO_VECTOR (Node));
0 commit comments