diff options
author | Dan Gohman <gohman@apple.com> | 2008-08-14 20:04:46 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-08-14 20:04:46 +0000 |
commit | 7f8613e5b8398b688080e3c944ab8c11593e1ed0 (patch) | |
tree | 2fe3e36cf3119d4e00b2da9dcaf673b464d9405b /lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | 22ae99908258dd5631fde7128a94c418ed08eae5 (diff) |
Improve support for vector casts in LLVM IR and CodeGen.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54784 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 9eab89ffb0..80dda1f280 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -2067,7 +2067,8 @@ SDValue SelectionDAG::getNode(unsigned Opcode, MVT VT, SDValue Operand) { unsigned OpOpcode = Operand.Val->getOpcode(); switch (Opcode) { case ISD::TokenFactor: - return Operand; // Factor of one node? No need. + case ISD::CONCAT_VECTORS: + return Operand; // Factor or concat of one node? No need. case ISD::FP_ROUND: assert(0 && "Invalid method to make FP_ROUND node"); case ISD::FP_EXTEND: assert(VT.isFloatingPoint() && @@ -2196,6 +2197,16 @@ SDValue SelectionDAG::getNode(unsigned Opcode, MVT VT, if (N1.getOpcode() == ISD::EntryToken) return N2; if (N2.getOpcode() == ISD::EntryToken) return N1; break; + case ISD::CONCAT_VECTORS: + // A CONCAT_VECTOR with all operands BUILD_VECTOR can be simplified to + // one big BUILD_VECTOR. + if (N1.getOpcode() == ISD::BUILD_VECTOR && + N2.getOpcode() == ISD::BUILD_VECTOR) { + SmallVector<SDValue, 16> Elts(N1.Val->op_begin(), N1.Val->op_end()); + Elts.insert(Elts.end(), N2.Val->op_begin(), N2.Val->op_end()); + return getNode(ISD::BUILD_VECTOR, VT, &Elts[0], Elts.size()); + } + break; case ISD::AND: assert(VT.isInteger() && N1.getValueType() == N2.getValueType() && N1.getValueType() == VT && "Binary operator types must match!"); @@ -2541,6 +2552,18 @@ SDValue SelectionDAG::getNode(unsigned Opcode, MVT VT, ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1.Val); ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N2.Val); switch (Opcode) { + case ISD::CONCAT_VECTORS: + // A CONCAT_VECTOR with all operands BUILD_VECTOR can be simplified to + // one big BUILD_VECTOR. + if (N1.getOpcode() == ISD::BUILD_VECTOR && + N2.getOpcode() == ISD::BUILD_VECTOR && + N3.getOpcode() == ISD::BUILD_VECTOR) { + SmallVector<SDValue, 16> Elts(N1.Val->op_begin(), N1.Val->op_end()); + Elts.insert(Elts.end(), N2.Val->op_begin(), N2.Val->op_end()); + Elts.insert(Elts.end(), N3.Val->op_begin(), N3.Val->op_end()); + return getNode(ISD::BUILD_VECTOR, VT, &Elts[0], Elts.size()); + } + break; case ISD::SETCC: { // Use FoldSetCC to simplify SETCC's. SDValue Simp = FoldSetCC(VT, N1, N2, cast<CondCodeSDNode>(N3)->get()); @@ -3179,7 +3202,8 @@ SelectionDAG::getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, } else { // Extending load. if (VT.isVector()) - assert(EVT == VT.getVectorElementType() && "Invalid vector extload!"); + assert(EVT.getVectorNumElements() == VT.getVectorNumElements() && + "Invalid vector extload!"); else assert(EVT.bitsLT(VT) && "Should only be an extending load, not truncating!"); |