Skip to content

Commit 4c4083f

Browse files
committed
Revert "remove dead code"
This reverts commit d1bab4d.
1 parent d1bab4d commit 4c4083f

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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,6 +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, 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+
15201542
SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack(SDNode* Node) {
15211543
assert((Node->getOpcode() == ISD::BUILD_VECTOR ||
15221544
Node->getOpcode() == ISD::CONCAT_VECTORS) &&
@@ -3375,7 +3397,12 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
33753397
Results.push_back(ExpandInsertToVectorThroughStack(SDValue(Node, 0)));
33763398
break;
33773399
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));
33793406
break;
33803407
case ISD::SCALAR_TO_VECTOR:
33813408
Results.push_back(ExpandSCALAR_TO_VECTOR(Node));

0 commit comments

Comments
 (0)