diff options
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 50 | 
1 files changed, 28 insertions, 22 deletions
| diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index cb15c4051fc..e0a3d54cf2f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -614,6 +614,32 @@ static void getCopyToParts(SelectionDAG &DAG, const SDLoc &DL, SDValue Val,      std::reverse(Parts, Parts + OrigNumParts);  } +static SDValue widenVectorToPartType(SelectionDAG &DAG, +                                     SDValue Val, const SDLoc &DL, EVT PartVT) { +  if (!PartVT.isVector()) +    return SDValue(); + +  EVT ValueVT = Val.getValueType(); +  unsigned PartNumElts = PartVT.getVectorNumElements(); +  unsigned ValueNumElts = ValueVT.getVectorNumElements(); +  if (PartNumElts > ValueNumElts && +      PartVT.getVectorElementType() == ValueVT.getVectorElementType()) { +    EVT ElementVT = PartVT.getVectorElementType(); +    // Vector widening case, e.g. <2 x float> -> <4 x float>.  Shuffle in +    // undef elements. +    SmallVector<SDValue, 16> Ops; +    DAG.ExtractVectorElements(Val, Ops); +    SDValue EltUndef = DAG.getUNDEF(ElementVT); +    for (unsigned i = ValueNumElts, e = PartNumElts; i != e; ++i) +      Ops.push_back(EltUndef); + +    // FIXME: Use CONCAT for 2x -> 4x. +    return DAG.getBuildVector(PartVT, DL, Ops); +  } + +  return SDValue(); +} +  /// getCopyToPartsVector - Create a series of nodes that contain the specified  /// value split into legal parts.  static void getCopyToPartsVector(SelectionDAG &DAG, const SDLoc &DL, @@ -632,28 +658,8 @@ static void getCopyToPartsVector(SelectionDAG &DAG, const SDLoc &DL,      } else if (PartVT.getSizeInBits() == ValueVT.getSizeInBits()) {        // Bitconvert vector->vector case.        Val = DAG.getNode(ISD::BITCAST, DL, PartVT, Val); -    } else if (PartVT.isVector() && -               PartEVT.getVectorElementType() == ValueVT.getVectorElementType() && -               PartEVT.getVectorNumElements() > ValueVT.getVectorNumElements()) { -      EVT ElementVT = PartVT.getVectorElementType(); -      // Vector widening case, e.g. <2 x float> -> <4 x float>.  Shuffle in -      // undef elements. -      SmallVector<SDValue, 16> Ops; -      for (unsigned i = 0, e = ValueVT.getVectorNumElements(); i != e; ++i) -        Ops.push_back(DAG.getNode( -            ISD::EXTRACT_VECTOR_ELT, DL, ElementVT, Val, -            DAG.getConstant(i, DL, TLI.getVectorIdxTy(DAG.getDataLayout())))); - -      for (unsigned i = ValueVT.getVectorNumElements(), -           e = PartVT.getVectorNumElements(); i != e; ++i) -        Ops.push_back(DAG.getUNDEF(ElementVT)); - -      Val = DAG.getBuildVector(PartVT, DL, Ops); - -      // FIXME: Use CONCAT for 2x -> 4x. - -      //SDValue UndefElts = DAG.getUNDEF(VectorTy); -      //Val = DAG.getNode(ISD::CONCAT_VECTORS, DL, PartVT, Val, UndefElts); +    } else if (SDValue Widened = widenVectorToPartType(DAG, Val, DL, PartVT)) { +      Val = Widened;      } else if (PartVT.isVector() &&                 PartEVT.getVectorElementType().bitsGE(                   ValueVT.getVectorElementType()) && | 

