Skip to content

Commit

Permalink
[AVX-512] Simplify the code added in r290870 to recognized 256-bit su…
Browse files Browse the repository at this point in the history
…bvector inserts and avoid calling isShuffleEquivalent on a widened mask.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290871 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
topperc committed Jan 3, 2017
1 parent 556d6a5 commit e89282e
Showing 1 changed file with 7 additions and 30 deletions.
37 changes: 7 additions & 30 deletions lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12590,8 +12590,8 @@ static SDValue lower256BitVectorShuffle(const SDLoc &DL, ArrayRef<int> Mask,
}
}

/// \brief Try to lower a vector shuffle as a 256-bit shuffle.
static SDValue lowerV2X256VectorShuffle(const SDLoc &DL, MVT VT,
/// \brief Try to lower a vector shuffle as a 128-bit shuffles.
static SDValue lowerV4X128VectorShuffle(const SDLoc &DL, MVT VT,
ArrayRef<int> Mask, SDValue V1,
SDValue V2, SelectionDAG &DAG) {
assert(VT.getScalarSizeInBits() == 64 &&
Expand All @@ -12601,16 +12601,16 @@ static SDValue lowerV2X256VectorShuffle(const SDLoc &DL, MVT VT,
// function lowerV2X128VectorShuffle() is better solution.
assert(VT.is512BitVector() && "Unexpected vector size for 512bit shuffle.");

assert(Mask.size() == 4 && "Expect mask to already be widened to 128-bits.");

SmallVector<int, 2> WidenedMask;
SmallVector<int, 4> WidenedMask;
if (!canWidenShuffleElements(Mask, WidenedMask))
return SDValue();

// Check for patterns which can be matched with a single insert of a 256-bit
// subvector.
bool OnlyUsesV1 = isShuffleEquivalent(V1, V2, WidenedMask, {0, 0});
if (OnlyUsesV1 || isShuffleEquivalent(V1, V2, WidenedMask, {0, 2})) {
bool OnlyUsesV1 = isShuffleEquivalent(V1, V2, Mask,
{0, 1, 2, 3, 0, 1, 2, 3});
if (OnlyUsesV1 || isShuffleEquivalent(V1, V2, Mask,
{0, 1, 2, 3, 8, 9, 10, 11})) {
MVT SubVT = MVT::getVectorVT(VT.getVectorElementType(),
VT.getVectorNumElements() / 2);
SDValue LoV = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, SubVT, V1,
Expand All @@ -12621,29 +12621,6 @@ static SDValue lowerV2X256VectorShuffle(const SDLoc &DL, MVT VT,
return DAG.getNode(ISD::CONCAT_VECTORS, DL, VT, LoV, HiV);
}

return SDValue();
}

/// \brief Try to lower a vector shuffle as a 128-bit shuffles.
static SDValue lowerV4X128VectorShuffle(const SDLoc &DL, MVT VT,
ArrayRef<int> Mask, SDValue V1,
SDValue V2, SelectionDAG &DAG) {
assert(VT.getScalarSizeInBits() == 64 &&
"Unexpected element type size for 128bit shuffle.");

// To handle 256 bit vector requires VLX and most probably
// function lowerV2X128VectorShuffle() is better solution.
assert(VT.is512BitVector() && "Unexpected vector size for 512bit shuffle.");

SmallVector<int, 4> WidenedMask;
if (!canWidenShuffleElements(Mask, WidenedMask))
return SDValue();

// See if we can widen even further to a 256-bit element.
if (SDValue Shuf256 = lowerV2X256VectorShuffle(DL, VT, WidenedMask, V1, V2,
DAG))
return Shuf256;

SDValue Ops[2] = {DAG.getUNDEF(VT), DAG.getUNDEF(VT)};
// Insure elements came from the same Op.
int MaxOp1Index = VT.getVectorNumElements()/2 - 1;
Expand Down

0 comments on commit e89282e

Please sign in to comment.