diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-03-23 21:16:34 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-03-23 21:16:34 +0000 |
| commit | d7c4e7d255b02ba10cb719043e1fe87b07965bc6 (patch) | |
| tree | fc22f46ee865cd8b540fd8b57bb79ed09a6f41cf /llvm/lib | |
| parent | 64b7e9ad913db0923eef11fd1cc5823842854cd0 (diff) | |
| download | bcm5719-llvm-d7c4e7d255b02ba10cb719043e1fe87b07965bc6.tar.gz bcm5719-llvm-d7c4e7d255b02ba10cb719043e1fe87b07965bc6.zip | |
add support for splitting casts. This implements
CodeGen/Generic/vector.ll:test_cast_2.
llvm-svn: 26999
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 0300d336bf6..e864e1894ce 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -4266,7 +4266,7 @@ void SelectionDAGLegalize::SplitVectorOp(SDOperand Op, SDOperand &Lo, } switch (Node->getOpcode()) { - default: assert(0 && "Unknown vector operation!"); + default: Node->dump(); assert(0 && "Unknown vector operation!"); case ISD::VBUILD_VECTOR: { std::vector<SDOperand> LoOps(Node->op_begin(), Node->op_begin()+NewNumElts); LoOps.push_back(NewNumEltsNode); @@ -4320,6 +4320,46 @@ void SelectionDAGLegalize::SplitVectorOp(SDOperand Op, SDOperand &Lo, std::swap(Lo, Hi); break; } + case ISD::VBIT_CONVERT: { + // We know the result is a vector. The input may be either a vector or a + // scalar value. + if (Op.getOperand(0).getValueType() != MVT::Vector) { + // Lower to a store/load. FIXME: this could be improved probably. + SDOperand Ptr = CreateStackTemporary(Op.getOperand(0).getValueType()); + + SDOperand St = DAG.getNode(ISD::STORE, MVT::Other, DAG.getEntryNode(), + Op.getOperand(0), Ptr, DAG.getSrcValue(0)); + MVT::ValueType EVT = cast<VTSDNode>(TypeNode)->getVT(); + St = DAG.getVecLoad(NumElements, EVT, St, Ptr, DAG.getSrcValue(0)); + SplitVectorOp(St, Lo, Hi); + } else { + // If the input is a vector type, we have to either scalarize it, pack it + // or convert it based on whether the input vector type is legal. + SDNode *InVal = Node->getOperand(0).Val; + unsigned NumElems = + cast<ConstantSDNode>(*(InVal->op_end()-2))->getValue(); + MVT::ValueType EVT = cast<VTSDNode>(*(InVal->op_end()-1))->getVT(); + + // If the input is from a single element vector, scalarize the vector, + // then treat like a scalar. + if (NumElems == 1) { + SDOperand Scalar = PackVectorOp(Op.getOperand(0), EVT); + Scalar = DAG.getNode(ISD::VBIT_CONVERT, MVT::Vector, Scalar, + Op.getOperand(1), Op.getOperand(2)); + SplitVectorOp(Scalar, Lo, Hi); + } else { + // Split the input vector. + SplitVectorOp(Op.getOperand(0), Lo, Hi); + + // Convert each of the pieces now. + Lo = DAG.getNode(ISD::VBIT_CONVERT, MVT::Vector, Lo, + NewNumEltsNode, TypeNode); + Hi = DAG.getNode(ISD::VBIT_CONVERT, MVT::Vector, Hi, + NewNumEltsNode, TypeNode); + } + break; + } + } } // Remember in a map if the values will be reused later. |

