diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 78cbcc66127..e0cf603fb41 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -7166,8 +7166,6 @@ bool isShuffleEquivalentImpl(ArrayRef Mask, ArrayRef Args) { return false; for (int i = 0, e = Mask.size(); i < e; ++i) { assert(*Args[i] >= 0 && "Arguments must be positive integers!"); - assert(*Args[i] < (int)Args.size() * 2 && - "Argument outside the range of possible shuffle inputs!"); if (Mask[i] != -1 && Mask[i] != *Args[i]) return false; } @@ -9344,6 +9342,12 @@ static SDValue lowerV8F32VectorShuffle(SDValue Op, SDValue V1, SDValue V2, if (isSingleInputShuffleMask(Mask)) return DAG.getNode(X86ISD::VPERMILP, DL, MVT::v8f32, V1, getV4X86ShuffleImm8ForMask(LoMask, DAG)); + + // Use dedicated unpack instructions for masks that match their pattern. + if (isShuffleEquivalent(LoMask, 0, 8, 1, 9)) + return DAG.getNode(X86ISD::UNPCKL, DL, MVT::v8f32, V1, V2); + if (isShuffleEquivalent(LoMask, 2, 10, 3, 11)) + return DAG.getNode(X86ISD::UNPCKH, DL, MVT::v8f32, V1, V2); } if (isSingleInputShuffleMask(Mask)) diff --git a/test/CodeGen/X86/vector-shuffle-256-v8.ll b/test/CodeGen/X86/vector-shuffle-256-v8.ll index 9ef27064fba..2d4f15769bb 100644 --- a/test/CodeGen/X86/vector-shuffle-256-v8.ll +++ b/test/CodeGen/X86/vector-shuffle-256-v8.ll @@ -196,9 +196,7 @@ define <8 x float> @shuffle_v8f32_9810dc54(<8 x float> %a, <8 x float> %b) { define <8 x float> @shuffle_v8f32_08194c5d(<8 x float> %a, <8 x float> %b) { ; ALL-LABEL: @shuffle_v8f32_08194c5d ; ALL: # BB#0: -; ALL-NEXT: vpermilps {{.*}} # ymm1 = ymm1[0,0,2,1,4,4,6,5] -; ALL-NEXT: vpermilps {{.*}} # ymm0 = ymm0[0,1,1,3,4,5,5,7] -; ALL-NEXT: vblendps {{.*}} # ymm0 = ymm0[0],ymm1[1],ymm0[2],ymm1[3],ymm0[4],ymm1[5],ymm0[6],ymm1[7] +; ALL-NEXT: vunpcklps {{.*}} # ymm0 = ymm0[0],ymm1[0],ymm0[1],ymm1[1],ymm0[4],ymm1[4],ymm0[5],ymm1[5] ; ALL-NEXT: retq %shuffle = shufflevector <8 x float> %a, <8 x float> %b, <8 x i32> ret <8 x float> %shuffle @@ -207,9 +205,7 @@ define <8 x float> @shuffle_v8f32_08194c5d(<8 x float> %a, <8 x float> %b) { define <8 x float> @shuffle_v8f32_2a3b6e7f(<8 x float> %a, <8 x float> %b) { ; ALL-LABEL: @shuffle_v8f32_2a3b6e7f ; ALL: # BB#0: -; ALL-NEXT: vpermilps {{.*}} # ymm1 = ymm1[0,2,2,3,4,6,6,7] -; ALL-NEXT: vpermilps {{.*}} # ymm0 = ymm0[2,1,3,3,6,5,7,7] -; ALL-NEXT: vblendps {{.*}} # ymm0 = ymm0[0],ymm1[1],ymm0[2],ymm1[3],ymm0[4],ymm1[5],ymm0[6],ymm1[7] +; ALL-NEXT: vunpckhps {{.*}} # ymm0 = ymm0[2],ymm1[2],ymm0[3],ymm1[3],ymm0[6],ymm1[6],ymm0[7],ymm1[7] ; ALL-NEXT: retq %shuffle = shufflevector <8 x float> %a, <8 x float> %b, <8 x i32> ret <8 x float> %shuffle