diff options
author | Scott Michel <scottm@aero.org> | 2009-02-22 23:36:09 +0000 |
---|---|---|
committer | Scott Michel <scottm@aero.org> | 2009-02-22 23:36:09 +0000 |
commit | 4214a5531cdbe538a358033f1847e55c4436be1b (patch) | |
tree | c2edc202e7449fbc8754f423a73864d5b8c7fd86 /lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | ca4286295f7db200724cb488a04ad15441a8ba99 (diff) |
Introduce the BuildVectorSDNode class that encapsulates the ISD::BUILD_VECTOR
instruction. The class also consolidates the code for detecting constant
splats that's shared across PowerPC and the CellSPU backends (and might be
useful for other backends.) Also introduces SelectionDAG::getBUID_VECTOR() for
generating new BUILD_VECTOR nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65296 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 4b3935c217..883f66afb1 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -2386,8 +2386,7 @@ SDValue DAGCombiner::visitXOR(SDNode *N) { // Produce a vector of zeros. SDValue El = DAG.getConstant(0, VT.getVectorElementType()); std::vector<SDValue> Ops(VT.getVectorNumElements(), El); - return DAG.getNode(ISD::BUILD_VECTOR, N->getDebugLoc(), VT, - &Ops[0], Ops.size()); + return DAG.getBUILD_VECTOR(VT, N->getDebugLoc(), &Ops[0], Ops.size()); } } @@ -3858,8 +3857,7 @@ ConstantFoldBIT_CONVERTofBUILD_VECTOR(SDNode *BV, MVT DstEltVT) { } MVT VT = MVT::getVectorVT(DstEltVT, BV->getValueType(0).getVectorNumElements()); - return DAG.getNode(ISD::BUILD_VECTOR, BV->getDebugLoc(), VT, - &Ops[0], Ops.size()); + return DAG.getBUILD_VECTOR(VT, BV->getDebugLoc(), &Ops[0], Ops.size()); } // Otherwise, we're growing or shrinking the elements. To avoid having to @@ -3915,8 +3913,7 @@ ConstantFoldBIT_CONVERTofBUILD_VECTOR(SDNode *BV, MVT DstEltVT) { } MVT VT = MVT::getVectorVT(DstEltVT, Ops.size()); - return DAG.getNode(ISD::BUILD_VECTOR, BV->getDebugLoc(), VT, - &Ops[0], Ops.size()); + return DAG.getBUILD_VECTOR(VT, BV->getDebugLoc(), &Ops[0], Ops.size()); } // Finally, this must be the case where we are shrinking elements: each input @@ -3950,8 +3947,7 @@ ConstantFoldBIT_CONVERTofBUILD_VECTOR(SDNode *BV, MVT DstEltVT) { std::reverse(Ops.end()-NumOutputsPerInput, Ops.end()); } - return DAG.getNode(ISD::BUILD_VECTOR, BV->getDebugLoc(), VT, - &Ops[0], Ops.size()); + return DAG.getBUILD_VECTOR(VT, BV->getDebugLoc(), &Ops[0], Ops.size()); } SDValue DAGCombiner::visitFADD(SDNode *N) { @@ -5084,8 +5080,8 @@ SDValue DAGCombiner::visitINSERT_VECTOR_ELT(SDNode *N) { InVec.getNode()->op_end()); if (Elt < Ops.size()) Ops[Elt] = InVal; - return DAG.getNode(ISD::BUILD_VECTOR, N->getDebugLoc(), - InVec.getValueType(), &Ops[0], Ops.size()); + return DAG.getBUILD_VECTOR(InVec.getValueType(), N->getDebugLoc(), + &Ops[0], Ops.size()); } return SDValue(); @@ -5270,13 +5266,13 @@ SDValue DAGCombiner::visitBUILD_VECTOR(SDNode *N) { // Use an undef build_vector as input for the second operand. std::vector<SDValue> UnOps(NumInScalars, DAG.getUNDEF(EltType)); - Ops[1] = DAG.getNode(ISD::BUILD_VECTOR, N->getDebugLoc(), VT, - &UnOps[0], UnOps.size()); + Ops[1] = DAG.getBUILD_VECTOR(VT, N->getDebugLoc(), + &UnOps[0], UnOps.size()); AddToWorkList(Ops[1].getNode()); } - Ops[2] = DAG.getNode(ISD::BUILD_VECTOR, N->getDebugLoc(), BuildVecVT, - &BuildVecIndices[0], BuildVecIndices.size()); + Ops[2] = DAG.getBUILD_VECTOR(BuildVecVT, N->getDebugLoc(), + &BuildVecIndices[0], BuildVecIndices.size()); return DAG.getNode(ISD::VECTOR_SHUFFLE, N->getDebugLoc(), VT, Ops, 3); } @@ -5419,9 +5415,8 @@ SDValue DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) { } } - ShufMask = DAG.getNode(ISD::BUILD_VECTOR, N->getDebugLoc(), - ShufMask.getValueType(), - &MappedOps[0], MappedOps.size()); + ShufMask = DAG.getBUILD_VECTOR(ShufMask.getValueType(), N->getDebugLoc(), + &MappedOps[0], MappedOps.size()); AddToWorkList(ShufMask.getNode()); return DAG.getNode(ISD::VECTOR_SHUFFLE, N->getDebugLoc(), N->getValueType(0), N0, @@ -5471,10 +5466,10 @@ SDValue DAGCombiner::XformToShuffleWithZero(SDNode *N) { Ops.push_back(LHS); AddToWorkList(LHS.getNode()); std::vector<SDValue> ZeroOps(NumElts, DAG.getConstant(0, EVT)); - Ops.push_back(DAG.getNode(ISD::BUILD_VECTOR, N->getDebugLoc(), - VT, &ZeroOps[0], ZeroOps.size())); - Ops.push_back(DAG.getNode(ISD::BUILD_VECTOR, N->getDebugLoc(), - MaskVT, &IdxOps[0], IdxOps.size())); + Ops.push_back(DAG.getBUILD_VECTOR(VT, N->getDebugLoc(), + &ZeroOps[0], ZeroOps.size())); + Ops.push_back(DAG.getBUILD_VECTOR(MaskVT, N->getDebugLoc(), + &IdxOps[0], IdxOps.size())); SDValue Result = DAG.getNode(ISD::VECTOR_SHUFFLE, N->getDebugLoc(), VT, &Ops[0], Ops.size()); @@ -5543,8 +5538,7 @@ SDValue DAGCombiner::SimplifyVBinOp(SDNode *N) { if (Ops.size() == LHS.getNumOperands()) { MVT VT = LHS.getValueType(); - return DAG.getNode(ISD::BUILD_VECTOR, N->getDebugLoc(), VT, - &Ops[0], Ops.size()); + return DAG.getBUILD_VECTOR(VT, N->getDebugLoc(), &Ops[0], Ops.size()); } } |