Skip to content

Commit 621fa58

Browse files
committed
first try
1 parent 818bffc commit 621fa58

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
@@ -2356,28 +2356,6 @@ SDValue NVPTXTargetLowering::LowerSTACKSAVE(SDValue Op,
23562356
return DAG.getMergeValues({ASC, SDValue(SS.getNode(), 1)}, DL);
23572357
}
23582358

2359-
// By default CONCAT_VECTORS is lowered by ExpandVectorBuildThroughStack()
2360-
// (see LegalizeDAG.cpp). This is slow and uses local memory.
2361-
// We use extract/insert/build vector just as what LegalizeOp() does in llvm 2.5
2362-
SDValue
2363-
NVPTXTargetLowering::LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const {
2364-
SDNode *Node = Op.getNode();
2365-
SDLoc dl(Node);
2366-
SmallVector<SDValue, 8> Ops;
2367-
unsigned NumOperands = Node->getNumOperands();
2368-
for (unsigned i = 0; i < NumOperands; ++i) {
2369-
SDValue SubOp = Node->getOperand(i);
2370-
EVT VVT = SubOp.getNode()->getValueType(0);
2371-
EVT EltVT = VVT.getVectorElementType();
2372-
unsigned NumSubElem = VVT.getVectorNumElements();
2373-
for (unsigned j = 0; j < NumSubElem; ++j) {
2374-
Ops.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, SubOp,
2375-
DAG.getIntPtrConstant(j, dl)));
2376-
}
2377-
}
2378-
return DAG.getBuildVector(Node->getValueType(0), dl, Ops);
2379-
}
2380-
23812359
SDValue NVPTXTargetLowering::LowerBITCAST(SDValue Op, SelectionDAG &DAG) const {
23822360
// Handle bitcasting from v2i8 without hitting the default promotion
23832361
// strategy which goes through stack memory.
@@ -2920,8 +2898,6 @@ NVPTXTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
29202898
return LowerINSERT_VECTOR_ELT(Op, DAG);
29212899
case ISD::VECTOR_SHUFFLE:
29222900
return LowerVECTOR_SHUFFLE(Op, DAG);
2923-
case ISD::CONCAT_VECTORS:
2924-
return LowerCONCAT_VECTORS(Op, DAG);
29252901
case ISD::STORE:
29262902
return LowerSTORE(Op, DAG);
29272903
case ISD::LOAD:

llvm/lib/Target/NVPTX/NVPTXISelLowering.h

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

625625
SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
626-
SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const;
627626
SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
628627
SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
629628
SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;

0 commit comments

Comments
 (0)