From ed4ede0c29f15ac527ec322c838f866c05c6ec6a Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 1 Dec 2016 11:26:07 +0000 Subject: [PATCH] [X86][SSE] Added tests showing missed combines of shuffles with ANDs. llvm-svn: 288330 --- .../CodeGen/X86/vector-shuffle-combining-avx2.ll | 17 ++++++++++++++++ .../CodeGen/X86/vector-shuffle-combining-ssse3.ll | 23 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll b/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll index a316de2..02a33a70 100644 --- a/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll +++ b/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll @@ -86,6 +86,23 @@ define <32 x i8> @combine_and_pshufb(<32 x i8> %a0) { ret <32 x i8> %2 } +define <32 x i8> @combine_pshufb_and(<32 x i8> %a0) { +; X32-LABEL: combine_pshufb_and: +; X32: # BB#0: +; X32-NEXT: vpshufb {{.*#+}} ymm0 = ymm0[0,1],zero,zero,zero,zero,zero,zero,ymm0[8,9],zero,zero,zero,zero,zero,zero,ymm0[16,17],zero,zero,zero,zero,zero,zero,ymm0[24,25],zero,zero,zero,zero,zero,zero +; X32-NEXT: vpand {{\.LCPI.*}}, %ymm0, %ymm0 +; X32-NEXT: retl +; +; X64-LABEL: combine_pshufb_and: +; X64: # BB#0: +; X64-NEXT: vpshufb {{.*#+}} ymm0 = ymm0[0,1],zero,zero,zero,zero,zero,zero,ymm0[8,9],zero,zero,zero,zero,zero,zero,ymm0[16,17],zero,zero,zero,zero,zero,zero,ymm0[24,25],zero,zero,zero,zero,zero,zero +; X64-NEXT: vpand {{.*}}(%rip), %ymm0, %ymm0 +; X64-NEXT: retq + %1 = call <32 x i8> @llvm.x86.avx2.pshuf.b(<32 x i8> %a0, <32 x i8> ) + %2 = shufflevector <32 x i8> %1, <32 x i8> zeroinitializer, <32 x i32> + ret <32 x i8> %2 +} + define <4 x i64> @combine_permq_pshufb_as_vperm2i128(<4 x i64> %a0) { ; X32-LABEL: combine_permq_pshufb_as_vperm2i128: ; X32: # BB#0: diff --git a/llvm/test/CodeGen/X86/vector-shuffle-combining-ssse3.ll b/llvm/test/CodeGen/X86/vector-shuffle-combining-ssse3.ll index 8a6fdddd1..95e86d2 100644 --- a/llvm/test/CodeGen/X86/vector-shuffle-combining-ssse3.ll +++ b/llvm/test/CodeGen/X86/vector-shuffle-combining-ssse3.ll @@ -297,6 +297,29 @@ define <16 x i8> @combine_and_pshufb(<16 x i8> %a0) { ret <16 x i8> %2 } +define <16 x i8> @combine_pshufb_and(<16 x i8> %a0) { +; SSSE3-LABEL: combine_pshufb_and: +; SSSE3: # BB#0: +; SSSE3-NEXT: pshufb {{.*#+}} xmm0 = xmm0[0,1],zero,zero,zero,zero,zero,zero,xmm0[8,9],zero,zero,zero,zero,zero,zero +; SSSE3-NEXT: pand {{.*}}(%rip), %xmm0 +; SSSE3-NEXT: retq +; +; SSE41-LABEL: combine_pshufb_and: +; SSE41: # BB#0: +; SSE41-NEXT: pxor %xmm1, %xmm1 +; SSE41-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1,2,3],xmm0[4],xmm1[5,6,7] +; SSE41-NEXT: retq +; +; AVX-LABEL: combine_pshufb_and: +; AVX: # BB#0: +; AVX-NEXT: vpxor %xmm1, %xmm1, %xmm1 +; AVX-NEXT: vpblendw {{.*#+}} xmm0 = xmm1[0,1,2,3],xmm0[4],xmm1[5,6,7] +; AVX-NEXT: retq + %1 = call <16 x i8> @llvm.x86.ssse3.pshuf.b.128(<16 x i8> %a0, <16 x i8> ) + %2 = shufflevector <16 x i8> %1, <16 x i8> zeroinitializer, <16 x i32> + ret <16 x i8> %2 +} + define <16 x i8> @combine_pshufb_as_palignr(<16 x i8> %a0) { ; SSE-LABEL: combine_pshufb_as_palignr: ; SSE: # BB#0: -- 2.7.4