Skip to content

Commit 7c5d29b

Browse files
committed
first try
1 parent bf700c3 commit 7c5d29b

File tree

3 files changed

+22
-29
lines changed

3 files changed

+22
-29
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 22 additions & 4 deletions
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,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+
15201540
SDValue 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));

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,28 +2001,6 @@ SDValue NVPTXTargetLowering::LowerSTACKSAVE(SDValue Op,
20012001
return DAG.getMergeValues({ASC, SDValue(SS.getNode(), 1)}, DL);
20022002
}
20032003

2004-
// By default CONCAT_VECTORS is lowered by ExpandVectorBuildThroughStack()
2005-
// (see LegalizeDAG.cpp). This is slow and uses local memory.
2006-
// We use extract/insert/build vector just as what LegalizeOp() does in llvm 2.5
2007-
SDValue
2008-
NVPTXTargetLowering::LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const {
2009-
SDNode *Node = Op.getNode();
2010-
SDLoc dl(Node);
2011-
SmallVector<SDValue, 8> Ops;
2012-
unsigned NumOperands = Node->getNumOperands();
2013-
for (unsigned i = 0; i < NumOperands; ++i) {
2014-
SDValue SubOp = Node->getOperand(i);
2015-
EVT VVT = SubOp.getNode()->getValueType(0);
2016-
EVT EltVT = VVT.getVectorElementType();
2017-
unsigned NumSubElem = VVT.getVectorNumElements();
2018-
for (unsigned j = 0; j < NumSubElem; ++j) {
2019-
Ops.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, SubOp,
2020-
DAG.getIntPtrConstant(j, dl)));
2021-
}
2022-
}
2023-
return DAG.getBuildVector(Node->getValueType(0), dl, Ops);
2024-
}
2025-
20262004
SDValue NVPTXTargetLowering::LowerBITCAST(SDValue Op, SelectionDAG &DAG) const {
20272005
// Handle bitcasting from v2i8 without hitting the default promotion
20282006
// strategy which goes through stack memory.
@@ -2565,8 +2543,6 @@ NVPTXTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
25652543
return LowerINSERT_VECTOR_ELT(Op, DAG);
25662544
case ISD::VECTOR_SHUFFLE:
25672545
return LowerVECTOR_SHUFFLE(Op, DAG);
2568-
case ISD::CONCAT_VECTORS:
2569-
return LowerCONCAT_VECTORS(Op, DAG);
25702546
case ISD::STORE:
25712547
return LowerSTORE(Op, DAG);
25722548
case ISD::LOAD:

llvm/lib/Target/NVPTX/NVPTXISelLowering.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ class NVPTXTargetLowering : public TargetLowering {
266266
SDValue LowerBITCAST(SDValue Op, SelectionDAG &DAG) const;
267267

268268
SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
269-
SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const;
270269
SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
271270
SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
272271
SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;

0 commit comments

Comments
 (0)