@@ -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);
@@ -1525,6 +1526,27 @@ SDValue SelectionDAGLegalize::ExpandInsertToVectorThroughStack(SDValue Op) {
1525
1526
BaseVecAlignment);
1526
1527
}
1527
1528
1529
+ SDValue SelectionDAGLegalize::ExpandConcatVectors (SDNode *Node) {
1530
+ assert (Node->getOpcode () == ISD::CONCAT_VECTORS && " Unexpected opcode!" );
1531
+ SDLoc DL (Node);
1532
+ SmallVector<SDValue, 16 > Ops;
1533
+ unsigned NumOperands = Node->getNumOperands ();
1534
+ MVT VectorIdxType = TLI.getVectorIdxTy (DAG.getDataLayout ());
1535
+ EVT VectorValueType = Node->getOperand (0 ).getValueType ();
1536
+ unsigned NumSubElem = VectorValueType.getVectorNumElements ();
1537
+ EVT ElementValueType = TLI.getTypeToTransformTo (
1538
+ *DAG.getContext (), VectorValueType.getVectorElementType ());
1539
+ for (unsigned I = 0 ; I < NumOperands; ++I) {
1540
+ SDValue SubOp = Node->getOperand (I);
1541
+ for (unsigned Idx = 0 ; Idx < NumSubElem; ++Idx) {
1542
+ Ops.push_back (DAG.getNode (ISD::EXTRACT_VECTOR_ELT, DL, ElementValueType,
1543
+ SubOp,
1544
+ DAG.getConstant (Idx, DL, VectorIdxType)));
1545
+ }
1546
+ }
1547
+ return DAG.getBuildVector (Node->getValueType (0 ), DL, Ops);
1548
+ }
1549
+
1528
1550
SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack (SDNode* Node) {
1529
1551
assert ((Node->getOpcode () == ISD::BUILD_VECTOR ||
1530
1552
Node->getOpcode () == ISD::CONCAT_VECTORS) &&
@@ -3383,7 +3405,12 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
3383
3405
Results.push_back (ExpandInsertToVectorThroughStack (SDValue (Node, 0 )));
3384
3406
break ;
3385
3407
case ISD::CONCAT_VECTORS:
3386
- Results.push_back (ExpandVectorBuildThroughStack (Node));
3408
+ if (EVT VectorValueType = Node->getOperand (0 ).getValueType ();
3409
+ VectorValueType.isScalableVector () ||
3410
+ TLI.isOperationExpand (ISD::EXTRACT_VECTOR_ELT, VectorValueType))
3411
+ Results.push_back (ExpandVectorBuildThroughStack (Node));
3412
+ else
3413
+ Results.push_back (ExpandConcatVectors (Node));
3387
3414
break ;
3388
3415
case ISD::SCALAR_TO_VECTOR:
3389
3416
Results.push_back (ExpandSCALAR_TO_VECTOR (Node));
0 commit comments