[llvm] r341392 - DAG: Factor out helper function for odd vector sizes
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 4 11:47:43 PDT 2018
Author: arsenm
Date: Tue Sep 4 11:47:43 2018
New Revision: 341392
URL: http://llvm.org/viewvc/llvm-project?rev=341392&view=rev
Log:
DAG: Factor out helper function for odd vector sizes
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=341392&r1=341391&r2=341392&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Sep 4 11:47:43 2018
@@ -614,6 +614,32 @@ static void getCopyToParts(SelectionDAG
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(Selecti
} 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()) &&
More information about the llvm-commits
mailing list