forked from OSchip/llvm-project
[x86] Switch the blend implementation to use a MVT switch rather than
awkward conditions. The readability improvement of this will be even more important as I generalize it to handle more types. No functionality changed. llvm-svn: 218205
This commit is contained in:
parent
f098cee2e3
commit
8d0a1b209b
|
@ -7234,27 +7234,34 @@ static SDValue lowerVectorShuffleAsBlend(SDLoc DL, MVT VT, SDValue V1,
|
||||||
if (Mask[i] >= 0 && Mask[i] != i)
|
if (Mask[i] >= 0 && Mask[i] != i)
|
||||||
return SDValue(); // Shuffled V1 input!
|
return SDValue(); // Shuffled V1 input!
|
||||||
}
|
}
|
||||||
if (VT == MVT::v4f32 || VT == MVT::v2f64)
|
switch (VT.SimpleTy) {
|
||||||
|
case MVT::v2f64:
|
||||||
|
case MVT::v4f32:
|
||||||
return DAG.getNode(X86ISD::BLENDI, DL, VT, V1, V2,
|
return DAG.getNode(X86ISD::BLENDI, DL, VT, V1, V2,
|
||||||
DAG.getConstant(BlendMask, MVT::i8));
|
DAG.getConstant(BlendMask, MVT::i8));
|
||||||
assert(!VT.isFloatingPoint() && "Only v4f32 and v2f64 are supported!");
|
|
||||||
|
|
||||||
// For integer shuffles we need to expand the mask and cast the inputs to
|
case MVT::v8i16:
|
||||||
// v8i16s prior to blending.
|
case MVT::v4i32:
|
||||||
assert((VT == MVT::v8i16 || VT == MVT::v4i32 || VT == MVT::v2i64) &&
|
case MVT::v2i64: {
|
||||||
"Not a supported integer vector type!");
|
// For integer shuffles we need to expand the mask and cast the inputs to
|
||||||
int Scale = 8 / VT.getVectorNumElements();
|
// v8i16s prior to blending.
|
||||||
BlendMask = 0;
|
int Scale = 8 / VT.getVectorNumElements();
|
||||||
for (int i = 0, Size = Mask.size(); i < Size; ++i)
|
BlendMask = 0;
|
||||||
if (Mask[i] >= Size)
|
for (int i = 0, Size = Mask.size(); i < Size; ++i)
|
||||||
for (int j = 0; j < Scale; ++j)
|
if (Mask[i] >= Size)
|
||||||
BlendMask |= 1u << (i * Scale + j);
|
for (int j = 0; j < Scale; ++j)
|
||||||
|
BlendMask |= 1u << (i * Scale + j);
|
||||||
|
|
||||||
V1 = DAG.getNode(ISD::BITCAST, DL, MVT::v8i16, V1);
|
V1 = DAG.getNode(ISD::BITCAST, DL, MVT::v8i16, V1);
|
||||||
V2 = DAG.getNode(ISD::BITCAST, DL, MVT::v8i16, V2);
|
V2 = DAG.getNode(ISD::BITCAST, DL, MVT::v8i16, V2);
|
||||||
return DAG.getNode(ISD::BITCAST, DL, VT,
|
return DAG.getNode(ISD::BITCAST, DL, VT,
|
||||||
DAG.getNode(X86ISD::BLENDI, DL, MVT::v8i16, V1, V2,
|
DAG.getNode(X86ISD::BLENDI, DL, MVT::v8i16, V1, V2,
|
||||||
DAG.getConstant(BlendMask, MVT::i8)));
|
DAG.getConstant(BlendMask, MVT::i8)));
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
llvm_unreachable("Not a supported integer vector type!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Try to lower a vector shuffle as a byte rotation.
|
/// \brief Try to lower a vector shuffle as a byte rotation.
|
||||||
|
|
Loading…
Reference in New Issue