[llvm] r290871 - [AVX-512] Simplify the code added in r290870 to recognized 256-bit subvector inserts and avoid calling isShuffleEquivalent on a widened mask.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 2 23:36:39 PST 2017


Author: ctopper
Date: Tue Jan  3 01:36:39 2017
New Revision: 290871

URL: http://llvm.org/viewvc/llvm-project?rev=290871&view=rev
Log:
[AVX-512] Simplify the code added in r290870 to recognized 256-bit subvector inserts and avoid calling isShuffleEquivalent on a widened mask.

Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=290871&r1=290870&r2=290871&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Jan  3 01:36:39 2017
@@ -12590,8 +12590,8 @@ static SDValue lower256BitVectorShuffle(
   }
 }
 
-/// \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 &&
@@ -12601,16 +12601,16 @@ static SDValue lowerV2X256VectorShuffle(
   // 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,
@@ -12621,29 +12621,6 @@ static SDValue lowerV2X256VectorShuffle(
     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;




More information about the llvm-commits mailing list