@@ -191,6 +191,7 @@ class SelectionDAGLegalize {
191191 SDValue ExpandExtractFromVectorThroughStack (SDValue Op);
192192 SDValue ExpandInsertToVectorThroughStack (SDValue Op);
193193 SDValue ExpandVectorBuildThroughStack (SDNode* Node);
194+ SDValue ExpandConcatVectors (SDNode* Node);
194195
195196 SDValue ExpandConstantFP (ConstantFPSDNode *CFP, bool UseCP);
196197 SDValue ExpandConstant (ConstantSDNode *CP);
@@ -1517,10 +1518,27 @@ SDValue SelectionDAGLegalize::ExpandInsertToVectorThroughStack(SDValue Op) {
15171518 BaseVecAlignment);
15181519}
15191520
1521+ SDValue SelectionDAGLegalize::ExpandConcatVectors (SDNode *Node) {
1522+ assert (Node->getOpcode () == ISD::CONCAT_VECTORS && " Unexpected opcode!" );
1523+ SDLoc Dl (Node);
1524+ SmallVector<SDValue, 0 > Ops;
1525+ unsigned NumOperands = Node->getNumOperands ();
1526+ for (unsigned I = 0 ; I < NumOperands; ++I) {
1527+ SDValue SubOp = Node->getOperand (I);
1528+ EVT VectorValueType =
1529+ SubOp->getValueType (0 );
1530+ EVT ElementValueType = VectorValueType.getVectorElementType ();
1531+ unsigned NumSubElem = VectorValueType.getVectorNumElements ();
1532+ for (unsigned J = 0 ; J < NumSubElem; ++J) {
1533+ Ops.push_back (DAG.getNode (ISD::EXTRACT_VECTOR_ELT, Dl, ElementValueType,
1534+ SubOp, DAG.getIntPtrConstant (J, Dl)));
1535+ }
1536+ }
1537+ return DAG.getBuildVector (Node->getValueType (0 ), Dl, Ops);
1538+ }
1539+
15201540SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack (SDNode* Node) {
1521- assert ((Node->getOpcode () == ISD::BUILD_VECTOR ||
1522- Node->getOpcode () == ISD::CONCAT_VECTORS) &&
1523- " Unexpected opcode!" );
1541+ assert (Node->getOpcode () == ISD::BUILD_VECTOR && " Unexpected opcode!" );
15241542
15251543 // We can't handle this case efficiently. Allocate a sufficiently
15261544 // aligned object on the stack, store each operand into it, then load
@@ -3371,7 +3389,7 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
33713389 Results.push_back (ExpandInsertToVectorThroughStack (SDValue (Node, 0 )));
33723390 break ;
33733391 case ISD::CONCAT_VECTORS:
3374- Results.push_back (ExpandVectorBuildThroughStack (Node));
3392+ Results.push_back (ExpandConcatVectors (Node));
33753393 break ;
33763394 case ISD::SCALAR_TO_VECTOR:
33773395 Results.push_back (ExpandSCALAR_TO_VECTOR (Node));
0 commit comments