diff --git a/llvm/test/CodeGen/X86/vector-pack-128.ll b/llvm/test/CodeGen/X86/vector-pack-128.ll new file mode 100644 index 000000000000..9b0bbac0199d --- /dev/null +++ b/llvm/test/CodeGen/X86/vector-pack-128.ll @@ -0,0 +1,326 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=SSE,SSE2 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.2 | FileCheck %s --check-prefixes=SSE,SSE4 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=AVX,AVX1 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=AVX,AVX2 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512vl,+avx512f | FileCheck %s --check-prefixes=AVX,AVX512,AVX512F +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512vl,+avx512bw | FileCheck %s --check-prefixes=AVX,AVX512,AVX512BW + +; trunc(concat(x,y)) -> pack + +define <8 x i16> @trunc_concat_packssdw_128(<4 x i32> %a0, <4 x i32> %a1) nounwind { +; SSE-LABEL: trunc_concat_packssdw_128: +; SSE: # %bb.0: +; SSE-NEXT: psrad $17, %xmm0 +; SSE-NEXT: pand {{.*}}(%rip), %xmm1 +; SSE-NEXT: packssdw %xmm1, %xmm0 +; SSE-NEXT: retq +; +; AVX1-LABEL: trunc_concat_packssdw_128: +; AVX1: # %bb.0: +; AVX1-NEXT: vpsrad $17, %xmm0, %xmm0 +; AVX1-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX1-NEXT: vpackssdw %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_concat_packssdw_128: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsrad $17, %xmm0, %xmm0 +; AVX2-NEXT: vpbroadcastd {{.*#+}} xmm2 = [15,15,15,15] +; AVX2-NEXT: vpand %xmm2, %xmm1, %xmm1 +; AVX2-NEXT: vpackssdw %xmm1, %xmm0, %xmm0 +; AVX2-NEXT: retq +; +; AVX512-LABEL: trunc_concat_packssdw_128: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsrad $17, %xmm0, %xmm0 +; AVX512-NEXT: vpandd {{.*}}(%rip){1to4}, %xmm1, %xmm1 +; AVX512-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512-NEXT: vpmovdw %ymm0, %xmm0 +; AVX512-NEXT: vzeroupper +; AVX512-NEXT: retq + %1 = ashr <4 x i32> %a0, + %2 = and <4 x i32> %a1, + %3 = shufflevector <4 x i32> %1, <4 x i32> %2, <8 x i32> + %4 = trunc <8 x i32> %3 to <8 x i16> + ret <8 x i16> %4 +} + +define <8 x i16> @trunc_concat_packusdw_128(<4 x i32> %a0, <4 x i32> %a1) nounwind { +; SSE2-LABEL: trunc_concat_packusdw_128: +; SSE2: # %bb.0: +; SSE2-NEXT: psrld $17, %xmm0 +; SSE2-NEXT: pand {{.*}}(%rip), %xmm1 +; SSE2-NEXT: packssdw %xmm1, %xmm0 +; SSE2-NEXT: retq +; +; SSE4-LABEL: trunc_concat_packusdw_128: +; SSE4: # %bb.0: +; SSE4-NEXT: psrld $17, %xmm0 +; SSE4-NEXT: pand {{.*}}(%rip), %xmm1 +; SSE4-NEXT: packusdw %xmm1, %xmm0 +; SSE4-NEXT: retq +; +; AVX1-LABEL: trunc_concat_packusdw_128: +; AVX1: # %bb.0: +; AVX1-NEXT: vpsrld $17, %xmm0, %xmm0 +; AVX1-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX1-NEXT: vpackusdw %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_concat_packusdw_128: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsrld $17, %xmm0, %xmm0 +; AVX2-NEXT: vpbroadcastd {{.*#+}} xmm2 = [15,15,15,15] +; AVX2-NEXT: vpand %xmm2, %xmm1, %xmm1 +; AVX2-NEXT: vpackusdw %xmm1, %xmm0, %xmm0 +; AVX2-NEXT: retq +; +; AVX512-LABEL: trunc_concat_packusdw_128: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsrld $17, %xmm0, %xmm0 +; AVX512-NEXT: vpandd {{.*}}(%rip){1to4}, %xmm1, %xmm1 +; AVX512-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512-NEXT: vpmovdw %ymm0, %xmm0 +; AVX512-NEXT: vzeroupper +; AVX512-NEXT: retq + %1 = lshr <4 x i32> %a0, + %2 = and <4 x i32> %a1, + %3 = shufflevector <4 x i32> %1, <4 x i32> %2, <8 x i32> + %4 = trunc <8 x i32> %3 to <8 x i16> + ret <8 x i16> %4 +} + +define <16 x i8> @trunc_concat_packsswb_128(<8 x i16> %a0, <8 x i16> %a1) nounwind { +; SSE-LABEL: trunc_concat_packsswb_128: +; SSE: # %bb.0: +; SSE-NEXT: psraw $15, %xmm0 +; SSE-NEXT: pand {{.*}}(%rip), %xmm1 +; SSE-NEXT: packsswb %xmm1, %xmm0 +; SSE-NEXT: retq +; +; AVX1-LABEL: trunc_concat_packsswb_128: +; AVX1: # %bb.0: +; AVX1-NEXT: vpsraw $15, %xmm0, %xmm0 +; AVX1-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX1-NEXT: vpacksswb %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_concat_packsswb_128: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsraw $15, %xmm0, %xmm0 +; AVX2-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX2-NEXT: vpacksswb %xmm1, %xmm0, %xmm0 +; AVX2-NEXT: retq +; +; AVX512F-LABEL: trunc_concat_packsswb_128: +; AVX512F: # %bb.0: +; AVX512F-NEXT: vpsraw $15, %xmm0, %xmm0 +; AVX512F-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX512F-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm0 = ymm0[0],zero,ymm0[1],zero,ymm0[2],zero,ymm0[3],zero,ymm0[4],zero,ymm0[5],zero,ymm0[6],zero,ymm0[7],zero,ymm0[8],zero,ymm0[9],zero,ymm0[10],zero,ymm0[11],zero,ymm0[12],zero,ymm0[13],zero,ymm0[14],zero,ymm0[15],zero +; AVX512F-NEXT: vpmovdb %zmm0, %xmm0 +; AVX512F-NEXT: vzeroupper +; AVX512F-NEXT: retq +; +; AVX512BW-LABEL: trunc_concat_packsswb_128: +; AVX512BW: # %bb.0: +; AVX512BW-NEXT: vpsraw $15, %xmm0, %xmm0 +; AVX512BW-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX512BW-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512BW-NEXT: vpmovwb %ymm0, %xmm0 +; AVX512BW-NEXT: vzeroupper +; AVX512BW-NEXT: retq + %1 = ashr <8 x i16> %a0, + %2 = and <8 x i16> %a1, + %3 = shufflevector <8 x i16> %1, <8 x i16> %2, <16 x i32> + %4 = trunc <16 x i16> %3 to <16 x i8> + ret <16 x i8> %4 +} + +define <16 x i8> @trunc_concat_packuswb_128(<8 x i16> %a0, <8 x i16> %a1) nounwind { +; SSE-LABEL: trunc_concat_packuswb_128: +; SSE: # %bb.0: +; SSE-NEXT: psrlw $15, %xmm0 +; SSE-NEXT: pand {{.*}}(%rip), %xmm1 +; SSE-NEXT: packuswb %xmm1, %xmm0 +; SSE-NEXT: retq +; +; AVX1-LABEL: trunc_concat_packuswb_128: +; AVX1: # %bb.0: +; AVX1-NEXT: vpsrlw $15, %xmm0, %xmm0 +; AVX1-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX1-NEXT: vpackuswb %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_concat_packuswb_128: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsrlw $15, %xmm0, %xmm0 +; AVX2-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX2-NEXT: vpackuswb %xmm1, %xmm0, %xmm0 +; AVX2-NEXT: retq +; +; AVX512F-LABEL: trunc_concat_packuswb_128: +; AVX512F: # %bb.0: +; AVX512F-NEXT: vpsrlw $15, %xmm0, %xmm0 +; AVX512F-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX512F-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm0 = ymm0[0],zero,ymm0[1],zero,ymm0[2],zero,ymm0[3],zero,ymm0[4],zero,ymm0[5],zero,ymm0[6],zero,ymm0[7],zero,ymm0[8],zero,ymm0[9],zero,ymm0[10],zero,ymm0[11],zero,ymm0[12],zero,ymm0[13],zero,ymm0[14],zero,ymm0[15],zero +; AVX512F-NEXT: vpmovdb %zmm0, %xmm0 +; AVX512F-NEXT: vzeroupper +; AVX512F-NEXT: retq +; +; AVX512BW-LABEL: trunc_concat_packuswb_128: +; AVX512BW: # %bb.0: +; AVX512BW-NEXT: vpsrlw $15, %xmm0, %xmm0 +; AVX512BW-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX512BW-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512BW-NEXT: vpmovwb %ymm0, %xmm0 +; AVX512BW-NEXT: vzeroupper +; AVX512BW-NEXT: retq + %1 = lshr <8 x i16> %a0, + %2 = and <8 x i16> %a1, + %3 = shufflevector <8 x i16> %1, <8 x i16> %2, <16 x i32> + %4 = trunc <16 x i16> %3 to <16 x i8> + ret <16 x i8> %4 +} + +; concat(trunc(x),trunc(y)) -> pack + +define <8 x i16> @concat_trunc_packssdw_128(<4 x i32> %a0, <4 x i32> %a1) nounwind { +; SSE2-LABEL: concat_trunc_packssdw_128: +; SSE2: # %bb.0: +; SSE2-NEXT: psrad $17, %xmm0 +; SSE2-NEXT: pand {{.*}}(%rip), %xmm1 +; SSE2-NEXT: packssdw %xmm0, %xmm0 +; SSE2-NEXT: packuswb %xmm1, %xmm1 +; SSE2-NEXT: punpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; SSE2-NEXT: retq +; +; SSE4-LABEL: concat_trunc_packssdw_128: +; SSE4: # %bb.0: +; SSE4-NEXT: psrad $17, %xmm0 +; SSE4-NEXT: pand {{.*}}(%rip), %xmm1 +; SSE4-NEXT: packssdw %xmm1, %xmm0 +; SSE4-NEXT: retq +; +; AVX1-LABEL: concat_trunc_packssdw_128: +; AVX1: # %bb.0: +; AVX1-NEXT: vpsrad $17, %xmm0, %xmm0 +; AVX1-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX1-NEXT: vpackssdw %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: concat_trunc_packssdw_128: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsrad $17, %xmm0, %xmm0 +; AVX2-NEXT: vpbroadcastd {{.*#+}} xmm2 = [15,15,15,15] +; AVX2-NEXT: vpand %xmm2, %xmm1, %xmm1 +; AVX2-NEXT: vpackssdw %xmm0, %xmm0, %xmm0 +; AVX2-NEXT: vpackusdw %xmm1, %xmm1, %xmm1 +; AVX2-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; AVX2-NEXT: retq +; +; AVX512-LABEL: concat_trunc_packssdw_128: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsrad $17, %xmm0, %xmm0 +; AVX512-NEXT: vpandd {{.*}}(%rip){1to4}, %xmm1, %xmm1 +; AVX512-NEXT: vpackssdw %xmm1, %xmm0, %xmm0 +; AVX512-NEXT: retq + %1 = ashr <4 x i32> %a0, + %2 = and <4 x i32> %a1, + %3 = trunc <4 x i32> %1 to <4 x i16> + %4 = trunc <4 x i32> %2 to <4 x i16> + %5 = shufflevector <4 x i16> %3, <4 x i16> %4, <8 x i32> + ret <8 x i16> %5 +} + +define <8 x i16> @concat_trunc_packusdw_128(<4 x i32> %a0, <4 x i32> %a1) nounwind { +; SSE2-LABEL: concat_trunc_packusdw_128: +; SSE2: # %bb.0: +; SSE2-NEXT: psrld $17, %xmm0 +; SSE2-NEXT: pand {{.*}}(%rip), %xmm1 +; SSE2-NEXT: packssdw %xmm0, %xmm0 +; SSE2-NEXT: packuswb %xmm1, %xmm1 +; SSE2-NEXT: punpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; SSE2-NEXT: retq +; +; SSE4-LABEL: concat_trunc_packusdw_128: +; SSE4: # %bb.0: +; SSE4-NEXT: psrld $17, %xmm0 +; SSE4-NEXT: pand {{.*}}(%rip), %xmm1 +; SSE4-NEXT: packusdw %xmm1, %xmm0 +; SSE4-NEXT: retq +; +; AVX1-LABEL: concat_trunc_packusdw_128: +; AVX1: # %bb.0: +; AVX1-NEXT: vpsrld $17, %xmm0, %xmm0 +; AVX1-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX1-NEXT: vpackusdw %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: concat_trunc_packusdw_128: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsrld $17, %xmm0, %xmm0 +; AVX2-NEXT: vpbroadcastd {{.*#+}} xmm2 = [15,15,15,15] +; AVX2-NEXT: vpand %xmm2, %xmm1, %xmm1 +; AVX2-NEXT: vpackusdw %xmm1, %xmm0, %xmm0 +; AVX2-NEXT: retq +; +; AVX512-LABEL: concat_trunc_packusdw_128: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsrld $17, %xmm0, %xmm0 +; AVX512-NEXT: vpandd {{.*}}(%rip){1to4}, %xmm1, %xmm1 +; AVX512-NEXT: vpackusdw %xmm1, %xmm0, %xmm0 +; AVX512-NEXT: retq + %1 = lshr <4 x i32> %a0, + %2 = and <4 x i32> %a1, + %3 = trunc <4 x i32> %1 to <4 x i16> + %4 = trunc <4 x i32> %2 to <4 x i16> + %5 = shufflevector <4 x i16> %3, <4 x i16> %4, <8 x i32> + ret <8 x i16> %5 +} + +define <16 x i8> @concat_trunc_packsswb_128(<8 x i16> %a0, <8 x i16> %a1) nounwind { +; SSE-LABEL: concat_trunc_packsswb_128: +; SSE: # %bb.0: +; SSE-NEXT: psraw $15, %xmm0 +; SSE-NEXT: pand {{.*}}(%rip), %xmm1 +; SSE-NEXT: packsswb %xmm1, %xmm0 +; SSE-NEXT: retq +; +; AVX-LABEL: concat_trunc_packsswb_128: +; AVX: # %bb.0: +; AVX-NEXT: vpsraw $15, %xmm0, %xmm0 +; AVX-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX-NEXT: vpacksswb %xmm1, %xmm0, %xmm0 +; AVX-NEXT: retq + %1 = ashr <8 x i16> %a0, + %2 = and <8 x i16> %a1, + %3 = trunc <8 x i16> %1 to <8 x i8> + %4 = trunc <8 x i16> %2 to <8 x i8> + %5 = shufflevector <8 x i8> %3, <8 x i8> %4, <16 x i32> + ret <16 x i8> %5 +} + +define <16 x i8> @concat_trunc_packuswb_128(<8 x i16> %a0, <8 x i16> %a1) nounwind { +; SSE-LABEL: concat_trunc_packuswb_128: +; SSE: # %bb.0: +; SSE-NEXT: psrlw $15, %xmm0 +; SSE-NEXT: pand {{.*}}(%rip), %xmm1 +; SSE-NEXT: packuswb %xmm1, %xmm0 +; SSE-NEXT: retq +; +; AVX-LABEL: concat_trunc_packuswb_128: +; AVX: # %bb.0: +; AVX-NEXT: vpsrlw $15, %xmm0, %xmm0 +; AVX-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX-NEXT: vpackuswb %xmm1, %xmm0, %xmm0 +; AVX-NEXT: retq + %1 = lshr <8 x i16> %a0, + %2 = and <8 x i16> %a1, + %3 = trunc <8 x i16> %1 to <8 x i8> + %4 = trunc <8 x i16> %2 to <8 x i8> + %5 = shufflevector <8 x i8> %3, <8 x i8> %4, <16 x i32> + ret <16 x i8> %5 +} diff --git a/llvm/test/CodeGen/X86/vector-pack-256.ll b/llvm/test/CodeGen/X86/vector-pack-256.ll new file mode 100644 index 000000000000..b1e72df9644e --- /dev/null +++ b/llvm/test/CodeGen/X86/vector-pack-256.ll @@ -0,0 +1,410 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=AVX,AVX1 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=AVX,AVX2 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512vl,+avx512f | FileCheck %s --check-prefixes=AVX,AVX512,AVX512F +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512vl,+avx512bw | FileCheck %s --check-prefixes=AVX,AVX512,AVX512BW + +; trunc(concat(x,y)) -> pack + +define <16 x i16> @trunc_concat_packssdw_256(<8 x i32> %a0, <8 x i32> %a1) nounwind { +; AVX1-LABEL: trunc_concat_packssdw_256: +; AVX1: # %bb.0: +; AVX1-NEXT: vpsrad $17, %xmm0, %xmm2 +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0 +; AVX1-NEXT: vpsrad $17, %xmm0, %xmm0 +; AVX1-NEXT: vpsrad $23, %xmm1, %xmm3 +; AVX1-NEXT: vpackssdw %xmm3, %xmm2, %xmm2 +; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm1 +; AVX1-NEXT: vpsrad $23, %xmm1, %xmm1 +; AVX1-NEXT: vpackssdw %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm2, %ymm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_concat_packssdw_256: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsrad $17, %ymm0, %ymm0 +; AVX2-NEXT: vpsrad $23, %ymm1, %ymm1 +; AVX2-NEXT: vperm2i128 {{.*#+}} ymm2 = ymm0[2,3],ymm1[2,3] +; AVX2-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX2-NEXT: vpackssdw %ymm2, %ymm0, %ymm0 +; AVX2-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,1,3] +; AVX2-NEXT: retq +; +; AVX512-LABEL: trunc_concat_packssdw_256: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsrad $17, %ymm0, %ymm0 +; AVX512-NEXT: vpsrad $23, %ymm1, %ymm1 +; AVX512-NEXT: vperm2i128 {{.*#+}} ymm2 = ymm0[2,3],ymm1[2,3] +; AVX512-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512-NEXT: vinserti64x4 $1, %ymm2, %zmm0, %zmm0 +; AVX512-NEXT: vpmovdw %zmm0, %ymm0 +; AVX512-NEXT: retq + %1 = ashr <8 x i32> %a0, + %2 = ashr <8 x i32> %a1, + %3 = shufflevector <8 x i32> %1, <8 x i32> %2, <16 x i32> + %4 = trunc <16 x i32> %3 to <16 x i16> + ret <16 x i16> %4 +} + +define <16 x i16> @trunc_concat_packusdw_256(<8 x i32> %a0, <8 x i32> %a1) nounwind { +; AVX1-LABEL: trunc_concat_packusdw_256: +; AVX1: # %bb.0: +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2 +; AVX1-NEXT: vpsrld $17, %xmm2, %xmm2 +; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm2 +; AVX1-NEXT: vpsrld $17, %xmm0, %xmm0 +; AVX1-NEXT: vandps {{.*}}(%rip), %ymm1, %ymm1 +; AVX1-NEXT: vperm2f128 {{.*#+}} ymm2 = ymm2[2,3],ymm1[2,3] +; AVX1-NEXT: vextractf128 $1, %ymm2, %xmm3 +; AVX1-NEXT: vpackusdw %xmm3, %xmm2, %xmm2 +; AVX1-NEXT: vpackusdw %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_concat_packusdw_256: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsrld $17, %ymm0, %ymm0 +; AVX2-NEXT: vpbroadcastd {{.*#+}} ymm2 = [15,15,15,15,15,15,15,15] +; AVX2-NEXT: vpand %ymm2, %ymm1, %ymm1 +; AVX2-NEXT: vperm2i128 {{.*#+}} ymm2 = ymm0[2,3],ymm1[2,3] +; AVX2-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX2-NEXT: vpackusdw %ymm2, %ymm0, %ymm0 +; AVX2-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,1,3] +; AVX2-NEXT: retq +; +; AVX512-LABEL: trunc_concat_packusdw_256: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsrld $17, %ymm0, %ymm0 +; AVX512-NEXT: vpandd {{.*}}(%rip){1to8}, %ymm1, %ymm1 +; AVX512-NEXT: vperm2i128 {{.*#+}} ymm2 = ymm0[2,3],ymm1[2,3] +; AVX512-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512-NEXT: vinserti64x4 $1, %ymm2, %zmm0, %zmm0 +; AVX512-NEXT: vpmovdw %zmm0, %ymm0 +; AVX512-NEXT: retq + %1 = lshr <8 x i32> %a0, + %2 = and <8 x i32> %a1, + %3 = shufflevector <8 x i32> %1, <8 x i32> %2, <16 x i32> + %4 = trunc <16 x i32> %3 to <16 x i16> + ret <16 x i16> %4 +} + +define <32 x i8> @trunc_concat_packsswb_256(<16 x i16> %a0, <16 x i16> %a1) nounwind { +; AVX1-LABEL: trunc_concat_packsswb_256: +; AVX1: # %bb.0: +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2 +; AVX1-NEXT: vpsraw $15, %xmm2, %xmm2 +; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm2 +; AVX1-NEXT: vpsraw $15, %xmm0, %xmm0 +; AVX1-NEXT: vandps {{.*}}(%rip), %ymm1, %ymm1 +; AVX1-NEXT: vperm2f128 {{.*#+}} ymm2 = ymm2[2,3],ymm1[2,3] +; AVX1-NEXT: vextractf128 $1, %ymm2, %xmm3 +; AVX1-NEXT: vpacksswb %xmm3, %xmm2, %xmm2 +; AVX1-NEXT: vpacksswb %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_concat_packsswb_256: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsraw $15, %ymm0, %ymm0 +; AVX2-NEXT: vpand {{.*}}(%rip), %ymm1, %ymm1 +; AVX2-NEXT: vperm2i128 {{.*#+}} ymm2 = ymm0[2,3],ymm1[2,3] +; AVX2-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX2-NEXT: vpacksswb %ymm2, %ymm0, %ymm0 +; AVX2-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,1,3] +; AVX2-NEXT: retq +; +; AVX512F-LABEL: trunc_concat_packsswb_256: +; AVX512F: # %bb.0: +; AVX512F-NEXT: vpsraw $15, %ymm0, %ymm0 +; AVX512F-NEXT: vpand {{.*}}(%rip), %ymm1, %ymm1 +; AVX512F-NEXT: vperm2i128 {{.*#+}} ymm2 = ymm0[2,3],ymm1[2,3] +; AVX512F-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm0 = ymm0[0],zero,ymm0[1],zero,ymm0[2],zero,ymm0[3],zero,ymm0[4],zero,ymm0[5],zero,ymm0[6],zero,ymm0[7],zero,ymm0[8],zero,ymm0[9],zero,ymm0[10],zero,ymm0[11],zero,ymm0[12],zero,ymm0[13],zero,ymm0[14],zero,ymm0[15],zero +; AVX512F-NEXT: vpmovdb %zmm0, %xmm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm1 = ymm2[0],zero,ymm2[1],zero,ymm2[2],zero,ymm2[3],zero,ymm2[4],zero,ymm2[5],zero,ymm2[6],zero,ymm2[7],zero,ymm2[8],zero,ymm2[9],zero,ymm2[10],zero,ymm2[11],zero,ymm2[12],zero,ymm2[13],zero,ymm2[14],zero,ymm2[15],zero +; AVX512F-NEXT: vpmovdb %zmm1, %xmm1 +; AVX512F-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512F-NEXT: retq +; +; AVX512BW-LABEL: trunc_concat_packsswb_256: +; AVX512BW: # %bb.0: +; AVX512BW-NEXT: vpsraw $15, %ymm0, %ymm0 +; AVX512BW-NEXT: vpand {{.*}}(%rip), %ymm1, %ymm1 +; AVX512BW-NEXT: vperm2i128 {{.*#+}} ymm2 = ymm0[2,3],ymm1[2,3] +; AVX512BW-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512BW-NEXT: vinserti64x4 $1, %ymm2, %zmm0, %zmm0 +; AVX512BW-NEXT: vpmovwb %zmm0, %ymm0 +; AVX512BW-NEXT: retq + %1 = ashr <16 x i16> %a0, + %2 = and <16 x i16> %a1, + %3 = shufflevector <16 x i16> %1, <16 x i16> %2, <32 x i32> + %4 = trunc <32 x i16> %3 to <32 x i8> + ret <32 x i8> %4 +} + +define <32 x i8> @trunc_concat_packuswb_256(<16 x i16> %a0, <16 x i16> %a1) nounwind { +; AVX1-LABEL: trunc_concat_packuswb_256: +; AVX1: # %bb.0: +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2 +; AVX1-NEXT: vpsrlw $15, %xmm2, %xmm2 +; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm2 +; AVX1-NEXT: vpsrlw $15, %xmm0, %xmm0 +; AVX1-NEXT: vandps {{.*}}(%rip), %ymm1, %ymm1 +; AVX1-NEXT: vperm2f128 {{.*#+}} ymm2 = ymm2[2,3],ymm1[2,3] +; AVX1-NEXT: vextractf128 $1, %ymm2, %xmm3 +; AVX1-NEXT: vpackuswb %xmm3, %xmm2, %xmm2 +; AVX1-NEXT: vpackuswb %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_concat_packuswb_256: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsrlw $15, %ymm0, %ymm0 +; AVX2-NEXT: vpand {{.*}}(%rip), %ymm1, %ymm1 +; AVX2-NEXT: vperm2i128 {{.*#+}} ymm2 = ymm0[2,3],ymm1[2,3] +; AVX2-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX2-NEXT: vpackuswb %ymm2, %ymm0, %ymm0 +; AVX2-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,1,3] +; AVX2-NEXT: retq +; +; AVX512F-LABEL: trunc_concat_packuswb_256: +; AVX512F: # %bb.0: +; AVX512F-NEXT: vpsrlw $15, %ymm0, %ymm0 +; AVX512F-NEXT: vpand {{.*}}(%rip), %ymm1, %ymm1 +; AVX512F-NEXT: vperm2i128 {{.*#+}} ymm2 = ymm0[2,3],ymm1[2,3] +; AVX512F-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm0 = ymm0[0],zero,ymm0[1],zero,ymm0[2],zero,ymm0[3],zero,ymm0[4],zero,ymm0[5],zero,ymm0[6],zero,ymm0[7],zero,ymm0[8],zero,ymm0[9],zero,ymm0[10],zero,ymm0[11],zero,ymm0[12],zero,ymm0[13],zero,ymm0[14],zero,ymm0[15],zero +; AVX512F-NEXT: vpmovdb %zmm0, %xmm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm1 = ymm2[0],zero,ymm2[1],zero,ymm2[2],zero,ymm2[3],zero,ymm2[4],zero,ymm2[5],zero,ymm2[6],zero,ymm2[7],zero,ymm2[8],zero,ymm2[9],zero,ymm2[10],zero,ymm2[11],zero,ymm2[12],zero,ymm2[13],zero,ymm2[14],zero,ymm2[15],zero +; AVX512F-NEXT: vpmovdb %zmm1, %xmm1 +; AVX512F-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512F-NEXT: retq +; +; AVX512BW-LABEL: trunc_concat_packuswb_256: +; AVX512BW: # %bb.0: +; AVX512BW-NEXT: vpsrlw $15, %ymm0, %ymm0 +; AVX512BW-NEXT: vpand {{.*}}(%rip), %ymm1, %ymm1 +; AVX512BW-NEXT: vperm2i128 {{.*#+}} ymm2 = ymm0[2,3],ymm1[2,3] +; AVX512BW-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512BW-NEXT: vinserti64x4 $1, %ymm2, %zmm0, %zmm0 +; AVX512BW-NEXT: vpmovwb %zmm0, %ymm0 +; AVX512BW-NEXT: retq + %1 = lshr <16 x i16> %a0, + %2 = and <16 x i16> %a1, + %3 = shufflevector <16 x i16> %1, <16 x i16> %2, <32 x i32> + %4 = trunc <32 x i16> %3 to <32 x i8> + ret <32 x i8> %4 +} + +; concat(trunc(x),trunc(y)) -> pack + + +define <16 x i16> @concat_trunc_packssdw_256(<8 x i32> %a0, <8 x i32> %a1) nounwind { +; AVX1-LABEL: concat_trunc_packssdw_256: +; AVX1: # %bb.0: +; AVX1-NEXT: vpsrad $17, %xmm0, %xmm2 +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0 +; AVX1-NEXT: vpsrad $17, %xmm0, %xmm0 +; AVX1-NEXT: vpsrad $23, %xmm1, %xmm3 +; AVX1-NEXT: vpackssdw %xmm3, %xmm2, %xmm2 +; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm1 +; AVX1-NEXT: vpsrad $23, %xmm1, %xmm1 +; AVX1-NEXT: vpackssdw %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm2, %ymm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: concat_trunc_packssdw_256: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsrad $17, %ymm0, %ymm0 +; AVX2-NEXT: vpsrad $23, %ymm1, %ymm1 +; AVX2-NEXT: vpackssdw %ymm1, %ymm0, %ymm0 +; AVX2-NEXT: retq +; +; AVX512-LABEL: concat_trunc_packssdw_256: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsrad $17, %ymm0, %ymm0 +; AVX512-NEXT: vpsrad $23, %ymm1, %ymm1 +; AVX512-NEXT: vpmovdw %ymm0, %xmm0 +; AVX512-NEXT: vpmovdw %ymm1, %xmm1 +; AVX512-NEXT: vpunpckhqdq {{.*#+}} xmm2 = xmm0[1],xmm1[1] +; AVX512-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; AVX512-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0 +; AVX512-NEXT: retq + %1 = ashr <8 x i32> %a0, + %2 = ashr <8 x i32> %a1, + %3 = trunc <8 x i32> %1 to <8 x i16> + %4 = trunc <8 x i32> %2 to <8 x i16> + %5 = shufflevector <8 x i16> %3, <8 x i16> %4, <16 x i32> + ret <16 x i16> %5 +} + +define <16 x i16> @concat_trunc_packusdw_256(<8 x i32> %a0, <8 x i32> %a1) nounwind { +; AVX1-LABEL: concat_trunc_packusdw_256: +; AVX1: # %bb.0: +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2 +; AVX1-NEXT: vpsrld $17, %xmm2, %xmm2 +; AVX1-NEXT: vpsrld $17, %xmm0, %xmm0 +; AVX1-NEXT: vpackusdw %xmm2, %xmm0, %xmm0 +; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm2 +; AVX1-NEXT: vmovdqa {{.*#+}} xmm3 = [0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15] +; AVX1-NEXT: vpshufb %xmm3, %xmm2, %xmm2 +; AVX1-NEXT: vpshufb %xmm3, %xmm1, %xmm1 +; AVX1-NEXT: vpunpcklqdq {{.*#+}} xmm1 = xmm1[0],xmm2[0] +; AVX1-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX1-NEXT: vpunpckhqdq {{.*#+}} xmm2 = xmm0[1],xmm1[1] +; AVX1-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: concat_trunc_packusdw_256: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsrld $17, %ymm0, %ymm0 +; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm2 +; AVX2-NEXT: vpackusdw %xmm2, %xmm0, %xmm0 +; AVX2-NEXT: vpshufb {{.*#+}} ymm1 = ymm1[0,1,4,5,8,9,12,13,u,u,u,u,u,u,u,u,16,17,20,21,24,25,28,29,u,u,u,u,u,u,u,u] +; AVX2-NEXT: vpermq {{.*#+}} ymm1 = ymm1[0,2,2,3] +; AVX2-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX2-NEXT: vpunpckhqdq {{.*#+}} xmm2 = xmm0[1],xmm1[1] +; AVX2-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; AVX2-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0 +; AVX2-NEXT: retq +; +; AVX512-LABEL: concat_trunc_packusdw_256: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsrld $17, %ymm0, %ymm0 +; AVX512-NEXT: vpmovdw %ymm0, %xmm0 +; AVX512-NEXT: vpmovdw %ymm1, %xmm1 +; AVX512-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX512-NEXT: vpunpckhqdq {{.*#+}} xmm2 = xmm0[1],xmm1[1] +; AVX512-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; AVX512-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0 +; AVX512-NEXT: retq + %1 = lshr <8 x i32> %a0, + %2 = and <8 x i32> %a1, + %3 = trunc <8 x i32> %1 to <8 x i16> + %4 = trunc <8 x i32> %2 to <8 x i16> + %5 = shufflevector <8 x i16> %3, <8 x i16> %4, <16 x i32> + ret <16 x i16> %5 +} + +define <32 x i8> @concat_trunc_packsswb_256(<16 x i16> %a0, <16 x i16> %a1) nounwind { +; AVX1-LABEL: concat_trunc_packsswb_256: +; AVX1: # %bb.0: +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2 +; AVX1-NEXT: vpsraw $15, %xmm2, %xmm2 +; AVX1-NEXT: vpsraw $15, %xmm0, %xmm0 +; AVX1-NEXT: vpacksswb %xmm2, %xmm0, %xmm0 +; AVX1-NEXT: vandps {{.*}}(%rip), %ymm1, %ymm1 +; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm2 +; AVX1-NEXT: vpackuswb %xmm2, %xmm1, %xmm1 +; AVX1-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX1-NEXT: vpunpckhqdq {{.*#+}} xmm2 = xmm0[1],xmm1[1] +; AVX1-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: concat_trunc_packsswb_256: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsraw $15, %ymm0, %ymm0 +; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm2 +; AVX2-NEXT: vpacksswb %xmm2, %xmm0, %xmm0 +; AVX2-NEXT: vpand {{.*}}(%rip), %ymm1, %ymm1 +; AVX2-NEXT: vextracti128 $1, %ymm1, %xmm2 +; AVX2-NEXT: vpackuswb %xmm2, %xmm1, %xmm1 +; AVX2-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX2-NEXT: vpunpckhqdq {{.*#+}} xmm2 = xmm0[1],xmm1[1] +; AVX2-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; AVX2-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0 +; AVX2-NEXT: retq +; +; AVX512F-LABEL: concat_trunc_packsswb_256: +; AVX512F: # %bb.0: +; AVX512F-NEXT: vpsraw $15, %ymm0, %ymm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm0 = ymm0[0],zero,ymm0[1],zero,ymm0[2],zero,ymm0[3],zero,ymm0[4],zero,ymm0[5],zero,ymm0[6],zero,ymm0[7],zero,ymm0[8],zero,ymm0[9],zero,ymm0[10],zero,ymm0[11],zero,ymm0[12],zero,ymm0[13],zero,ymm0[14],zero,ymm0[15],zero +; AVX512F-NEXT: vpmovdb %zmm0, %xmm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm1 = ymm1[0],zero,ymm1[1],zero,ymm1[2],zero,ymm1[3],zero,ymm1[4],zero,ymm1[5],zero,ymm1[6],zero,ymm1[7],zero,ymm1[8],zero,ymm1[9],zero,ymm1[10],zero,ymm1[11],zero,ymm1[12],zero,ymm1[13],zero,ymm1[14],zero,ymm1[15],zero +; AVX512F-NEXT: vpmovdb %zmm1, %xmm1 +; AVX512F-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX512F-NEXT: vpunpckhqdq {{.*#+}} xmm2 = xmm0[1],xmm1[1] +; AVX512F-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; AVX512F-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0 +; AVX512F-NEXT: retq +; +; AVX512BW-LABEL: concat_trunc_packsswb_256: +; AVX512BW: # %bb.0: +; AVX512BW-NEXT: vpsraw $15, %ymm0, %ymm0 +; AVX512BW-NEXT: vpmovwb %ymm0, %xmm0 +; AVX512BW-NEXT: vpmovwb %ymm1, %xmm1 +; AVX512BW-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX512BW-NEXT: vpunpckhqdq {{.*#+}} xmm2 = xmm0[1],xmm1[1] +; AVX512BW-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; AVX512BW-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0 +; AVX512BW-NEXT: retq + %1 = ashr <16 x i16> %a0, + %2 = and <16 x i16> %a1, + %3 = trunc <16 x i16> %1 to <16 x i8> + %4 = trunc <16 x i16> %2 to <16 x i8> + %5 = shufflevector <16 x i8> %3, <16 x i8> %4, <32 x i32> + ret <32 x i8> %5 +} + +define <32 x i8> @concat_trunc_packuswb_256(<16 x i16> %a0, <16 x i16> %a1) nounwind { +; AVX1-LABEL: concat_trunc_packuswb_256: +; AVX1: # %bb.0: +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2 +; AVX1-NEXT: vpsrlw $15, %xmm2, %xmm2 +; AVX1-NEXT: vpsrlw $15, %xmm0, %xmm0 +; AVX1-NEXT: vpackuswb %xmm2, %xmm0, %xmm0 +; AVX1-NEXT: vandps {{.*}}(%rip), %ymm1, %ymm1 +; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm2 +; AVX1-NEXT: vpackuswb %xmm2, %xmm1, %xmm1 +; AVX1-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX1-NEXT: vpunpckhqdq {{.*#+}} xmm2 = xmm0[1],xmm1[1] +; AVX1-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0 +; AVX1-NEXT: retq +; +; AVX2-LABEL: concat_trunc_packuswb_256: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsrlw $15, %ymm0, %ymm0 +; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm2 +; AVX2-NEXT: vpackuswb %xmm2, %xmm0, %xmm0 +; AVX2-NEXT: vpand {{.*}}(%rip), %ymm1, %ymm1 +; AVX2-NEXT: vextracti128 $1, %ymm1, %xmm2 +; AVX2-NEXT: vpackuswb %xmm2, %xmm1, %xmm1 +; AVX2-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX2-NEXT: vpunpckhqdq {{.*#+}} xmm2 = xmm0[1],xmm1[1] +; AVX2-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; AVX2-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0 +; AVX2-NEXT: retq +; +; AVX512F-LABEL: concat_trunc_packuswb_256: +; AVX512F: # %bb.0: +; AVX512F-NEXT: vpsrlw $15, %ymm0, %ymm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm0 = ymm0[0],zero,ymm0[1],zero,ymm0[2],zero,ymm0[3],zero,ymm0[4],zero,ymm0[5],zero,ymm0[6],zero,ymm0[7],zero,ymm0[8],zero,ymm0[9],zero,ymm0[10],zero,ymm0[11],zero,ymm0[12],zero,ymm0[13],zero,ymm0[14],zero,ymm0[15],zero +; AVX512F-NEXT: vpmovdb %zmm0, %xmm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm1 = ymm1[0],zero,ymm1[1],zero,ymm1[2],zero,ymm1[3],zero,ymm1[4],zero,ymm1[5],zero,ymm1[6],zero,ymm1[7],zero,ymm1[8],zero,ymm1[9],zero,ymm1[10],zero,ymm1[11],zero,ymm1[12],zero,ymm1[13],zero,ymm1[14],zero,ymm1[15],zero +; AVX512F-NEXT: vpmovdb %zmm1, %xmm1 +; AVX512F-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX512F-NEXT: vpunpckhqdq {{.*#+}} xmm2 = xmm0[1],xmm1[1] +; AVX512F-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; AVX512F-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0 +; AVX512F-NEXT: retq +; +; AVX512BW-LABEL: concat_trunc_packuswb_256: +; AVX512BW: # %bb.0: +; AVX512BW-NEXT: vpsrlw $15, %ymm0, %ymm0 +; AVX512BW-NEXT: vpmovwb %ymm0, %xmm0 +; AVX512BW-NEXT: vpmovwb %ymm1, %xmm1 +; AVX512BW-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1 +; AVX512BW-NEXT: vpunpckhqdq {{.*#+}} xmm2 = xmm0[1],xmm1[1] +; AVX512BW-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0] +; AVX512BW-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0 +; AVX512BW-NEXT: retq + %1 = lshr <16 x i16> %a0, + %2 = and <16 x i16> %a1, + %3 = trunc <16 x i16> %1 to <16 x i8> + %4 = trunc <16 x i16> %2 to <16 x i8> + %5 = shufflevector <16 x i8> %3, <16 x i8> %4, <32 x i32> + ret <32 x i8> %5 +} diff --git a/llvm/test/CodeGen/X86/vector-pack-512.ll b/llvm/test/CodeGen/X86/vector-pack-512.ll new file mode 100644 index 000000000000..0612e08e830a --- /dev/null +++ b/llvm/test/CodeGen/X86/vector-pack-512.ll @@ -0,0 +1,271 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512vl,+avx512f | FileCheck %s --check-prefixes=AVX512,AVX512F +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512vl,+avx512bw | FileCheck %s --check-prefixes=AVX512,AVX512BW + +; trunc(concat(x,y)) -> pack + +define <32 x i16> @trunc_concat_packssdw_512(<16 x i32> %a0, <16 x i32> %a1) nounwind { +; AVX512-LABEL: trunc_concat_packssdw_512: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsrad $17, %zmm0, %zmm0 +; AVX512-NEXT: vpsrad $23, %zmm1, %zmm1 +; AVX512-NEXT: vmovdqa64 {{.*#+}} zmm2 = [4,5,12,13,6,7,14,15] +; AVX512-NEXT: vpermi2q %zmm1, %zmm0, %zmm2 +; AVX512-NEXT: vmovdqa64 {{.*#+}} zmm3 = [0,1,8,9,2,3,10,11] +; AVX512-NEXT: vpermi2q %zmm1, %zmm0, %zmm3 +; AVX512-NEXT: vpmovdw %zmm3, %ymm0 +; AVX512-NEXT: vpmovdw %zmm2, %ymm1 +; AVX512-NEXT: vinserti64x4 $1, %ymm1, %zmm0, %zmm0 +; AVX512-NEXT: retq + %1 = ashr <16 x i32> %a0, + %2 = ashr <16 x i32> %a1, + %3 = shufflevector <16 x i32> %1, <16 x i32> %2, <32 x i32> + %4 = trunc <32 x i32> %3 to <32 x i16> + ret <32 x i16> %4 +} + +define <32 x i16> @trunc_concat_packusdw_512(<16 x i32> %a0, <16 x i32> %a1) nounwind { +; AVX512-LABEL: trunc_concat_packusdw_512: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsrld $17, %zmm0, %zmm0 +; AVX512-NEXT: vpandd {{.*}}(%rip){1to16}, %zmm1, %zmm1 +; AVX512-NEXT: vmovdqa64 {{.*#+}} zmm2 = [4,5,12,13,6,7,14,15] +; AVX512-NEXT: vpermi2q %zmm1, %zmm0, %zmm2 +; AVX512-NEXT: vmovdqa64 {{.*#+}} zmm3 = [0,1,8,9,2,3,10,11] +; AVX512-NEXT: vpermi2q %zmm1, %zmm0, %zmm3 +; AVX512-NEXT: vpmovdw %zmm3, %ymm0 +; AVX512-NEXT: vpmovdw %zmm2, %ymm1 +; AVX512-NEXT: vinserti64x4 $1, %ymm1, %zmm0, %zmm0 +; AVX512-NEXT: retq + %1 = lshr <16 x i32> %a0, + %2 = and <16 x i32> %a1, + %3 = shufflevector <16 x i32> %1, <16 x i32> %2, <32 x i32> + %4 = trunc <32 x i32> %3 to <32 x i16> + ret <32 x i16> %4 +} + +define <64 x i8> @trunc_concat_packsswb_512(<32 x i16> %a0, <32 x i16> %a1) nounwind { +; AVX512F-LABEL: trunc_concat_packsswb_512: +; AVX512F: # %bb.0: +; AVX512F-NEXT: vpsraw $15, %ymm0, %ymm2 +; AVX512F-NEXT: vextracti64x4 $1, %zmm0, %ymm0 +; AVX512F-NEXT: vpsraw $15, %ymm0, %ymm0 +; AVX512F-NEXT: vinserti64x4 $1, %ymm0, %zmm2, %zmm0 +; AVX512F-NEXT: vpandq {{.*}}(%rip), %zmm1, %zmm1 +; AVX512F-NEXT: vmovdqa64 {{.*#+}} zmm2 = [0,1,8,9,2,3,10,11] +; AVX512F-NEXT: vpermi2q %zmm1, %zmm0, %zmm2 +; AVX512F-NEXT: vmovdqa64 {{.*#+}} zmm3 = [4,5,12,13,6,7,14,15] +; AVX512F-NEXT: vpermi2q %zmm1, %zmm0, %zmm3 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm0 = ymm3[0],zero,ymm3[1],zero,ymm3[2],zero,ymm3[3],zero,ymm3[4],zero,ymm3[5],zero,ymm3[6],zero,ymm3[7],zero,ymm3[8],zero,ymm3[9],zero,ymm3[10],zero,ymm3[11],zero,ymm3[12],zero,ymm3[13],zero,ymm3[14],zero,ymm3[15],zero +; AVX512F-NEXT: vpmovdb %zmm0, %xmm0 +; AVX512F-NEXT: vextracti64x4 $1, %zmm3, %ymm1 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm1 = ymm1[0],zero,ymm1[1],zero,ymm1[2],zero,ymm1[3],zero,ymm1[4],zero,ymm1[5],zero,ymm1[6],zero,ymm1[7],zero,ymm1[8],zero,ymm1[9],zero,ymm1[10],zero,ymm1[11],zero,ymm1[12],zero,ymm1[13],zero,ymm1[14],zero,ymm1[15],zero +; AVX512F-NEXT: vpmovdb %zmm1, %xmm1 +; AVX512F-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm1 = ymm2[0],zero,ymm2[1],zero,ymm2[2],zero,ymm2[3],zero,ymm2[4],zero,ymm2[5],zero,ymm2[6],zero,ymm2[7],zero,ymm2[8],zero,ymm2[9],zero,ymm2[10],zero,ymm2[11],zero,ymm2[12],zero,ymm2[13],zero,ymm2[14],zero,ymm2[15],zero +; AVX512F-NEXT: vpmovdb %zmm1, %xmm1 +; AVX512F-NEXT: vextracti64x4 $1, %zmm2, %ymm2 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm2 = ymm2[0],zero,ymm2[1],zero,ymm2[2],zero,ymm2[3],zero,ymm2[4],zero,ymm2[5],zero,ymm2[6],zero,ymm2[7],zero,ymm2[8],zero,ymm2[9],zero,ymm2[10],zero,ymm2[11],zero,ymm2[12],zero,ymm2[13],zero,ymm2[14],zero,ymm2[15],zero +; AVX512F-NEXT: vpmovdb %zmm2, %xmm2 +; AVX512F-NEXT: vinserti128 $1, %xmm2, %ymm1, %ymm1 +; AVX512F-NEXT: vinserti64x4 $1, %ymm0, %zmm1, %zmm0 +; AVX512F-NEXT: retq +; +; AVX512BW-LABEL: trunc_concat_packsswb_512: +; AVX512BW: # %bb.0: +; AVX512BW-NEXT: vpsraw $15, %zmm0, %zmm0 +; AVX512BW-NEXT: vpandq {{.*}}(%rip), %zmm1, %zmm1 +; AVX512BW-NEXT: vmovdqa64 {{.*#+}} zmm2 = [4,5,12,13,6,7,14,15] +; AVX512BW-NEXT: vpermi2q %zmm1, %zmm0, %zmm2 +; AVX512BW-NEXT: vmovdqa64 {{.*#+}} zmm3 = [0,1,8,9,2,3,10,11] +; AVX512BW-NEXT: vpermi2q %zmm1, %zmm0, %zmm3 +; AVX512BW-NEXT: vpmovwb %zmm3, %ymm0 +; AVX512BW-NEXT: vpmovwb %zmm2, %ymm1 +; AVX512BW-NEXT: vinserti64x4 $1, %ymm1, %zmm0, %zmm0 +; AVX512BW-NEXT: retq + %1 = ashr <32 x i16> %a0, + %2 = and <32 x i16> %a1, + %3 = shufflevector <32 x i16> %1, <32 x i16> %2, <64 x i32> + %4 = trunc <64 x i16> %3 to <64 x i8> + ret <64 x i8> %4 +} + +define <64 x i8> @trunc_concat_packuswb_512(<32 x i16> %a0, <32 x i16> %a1) nounwind { +; AVX512F-LABEL: trunc_concat_packuswb_512: +; AVX512F: # %bb.0: +; AVX512F-NEXT: vpsrlw $15, %ymm0, %ymm2 +; AVX512F-NEXT: vextracti64x4 $1, %zmm0, %ymm0 +; AVX512F-NEXT: vpsrlw $15, %ymm0, %ymm0 +; AVX512F-NEXT: vinserti64x4 $1, %ymm0, %zmm2, %zmm0 +; AVX512F-NEXT: vpandq {{.*}}(%rip), %zmm1, %zmm1 +; AVX512F-NEXT: vmovdqa64 {{.*#+}} zmm2 = [0,1,8,9,2,3,10,11] +; AVX512F-NEXT: vpermi2q %zmm1, %zmm0, %zmm2 +; AVX512F-NEXT: vmovdqa64 {{.*#+}} zmm3 = [4,5,12,13,6,7,14,15] +; AVX512F-NEXT: vpermi2q %zmm1, %zmm0, %zmm3 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm0 = ymm3[0],zero,ymm3[1],zero,ymm3[2],zero,ymm3[3],zero,ymm3[4],zero,ymm3[5],zero,ymm3[6],zero,ymm3[7],zero,ymm3[8],zero,ymm3[9],zero,ymm3[10],zero,ymm3[11],zero,ymm3[12],zero,ymm3[13],zero,ymm3[14],zero,ymm3[15],zero +; AVX512F-NEXT: vpmovdb %zmm0, %xmm0 +; AVX512F-NEXT: vextracti64x4 $1, %zmm3, %ymm1 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm1 = ymm1[0],zero,ymm1[1],zero,ymm1[2],zero,ymm1[3],zero,ymm1[4],zero,ymm1[5],zero,ymm1[6],zero,ymm1[7],zero,ymm1[8],zero,ymm1[9],zero,ymm1[10],zero,ymm1[11],zero,ymm1[12],zero,ymm1[13],zero,ymm1[14],zero,ymm1[15],zero +; AVX512F-NEXT: vpmovdb %zmm1, %xmm1 +; AVX512F-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm1 = ymm2[0],zero,ymm2[1],zero,ymm2[2],zero,ymm2[3],zero,ymm2[4],zero,ymm2[5],zero,ymm2[6],zero,ymm2[7],zero,ymm2[8],zero,ymm2[9],zero,ymm2[10],zero,ymm2[11],zero,ymm2[12],zero,ymm2[13],zero,ymm2[14],zero,ymm2[15],zero +; AVX512F-NEXT: vpmovdb %zmm1, %xmm1 +; AVX512F-NEXT: vextracti64x4 $1, %zmm2, %ymm2 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm2 = ymm2[0],zero,ymm2[1],zero,ymm2[2],zero,ymm2[3],zero,ymm2[4],zero,ymm2[5],zero,ymm2[6],zero,ymm2[7],zero,ymm2[8],zero,ymm2[9],zero,ymm2[10],zero,ymm2[11],zero,ymm2[12],zero,ymm2[13],zero,ymm2[14],zero,ymm2[15],zero +; AVX512F-NEXT: vpmovdb %zmm2, %xmm2 +; AVX512F-NEXT: vinserti128 $1, %xmm2, %ymm1, %ymm1 +; AVX512F-NEXT: vinserti64x4 $1, %ymm0, %zmm1, %zmm0 +; AVX512F-NEXT: retq +; +; AVX512BW-LABEL: trunc_concat_packuswb_512: +; AVX512BW: # %bb.0: +; AVX512BW-NEXT: vpsrlw $15, %zmm0, %zmm0 +; AVX512BW-NEXT: vpandq {{.*}}(%rip), %zmm1, %zmm1 +; AVX512BW-NEXT: vmovdqa64 {{.*#+}} zmm2 = [4,5,12,13,6,7,14,15] +; AVX512BW-NEXT: vpermi2q %zmm1, %zmm0, %zmm2 +; AVX512BW-NEXT: vmovdqa64 {{.*#+}} zmm3 = [0,1,8,9,2,3,10,11] +; AVX512BW-NEXT: vpermi2q %zmm1, %zmm0, %zmm3 +; AVX512BW-NEXT: vpmovwb %zmm3, %ymm0 +; AVX512BW-NEXT: vpmovwb %zmm2, %ymm1 +; AVX512BW-NEXT: vinserti64x4 $1, %ymm1, %zmm0, %zmm0 +; AVX512BW-NEXT: retq + %1 = lshr <32 x i16> %a0, + %2 = and <32 x i16> %a1, + %3 = shufflevector <32 x i16> %1, <32 x i16> %2, <64 x i32> + %4 = trunc <64 x i16> %3 to <64 x i8> + ret <64 x i8> %4 +} + +; concat(trunc(x),trunc(y)) -> pack + +define <32 x i16> @concat_trunc_packssdw_512(<16 x i32> %a0, <16 x i32> %a1) nounwind { +; AVX512-LABEL: concat_trunc_packssdw_512: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsrad $17, %zmm0, %zmm0 +; AVX512-NEXT: vpsrad $23, %zmm1, %zmm1 +; AVX512-NEXT: vpmovdw %zmm0, %ymm0 +; AVX512-NEXT: vpmovdw %zmm1, %ymm1 +; AVX512-NEXT: vmovdqa {{.*#+}} ymm2 = [2,6,3,7] +; AVX512-NEXT: vpermi2q %ymm1, %ymm0, %ymm2 +; AVX512-NEXT: vmovdqa {{.*#+}} ymm3 = [0,4,1,5] +; AVX512-NEXT: vpermi2q %ymm1, %ymm0, %ymm3 +; AVX512-NEXT: vinserti64x4 $1, %ymm2, %zmm3, %zmm0 +; AVX512-NEXT: retq + %1 = ashr <16 x i32> %a0, + %2 = ashr <16 x i32> %a1, + %3 = trunc <16 x i32> %1 to <16 x i16> + %4 = trunc <16 x i32> %2 to <16 x i16> + %5 = shufflevector <16 x i16> %3, <16 x i16> %4, <32 x i32> + ret <32 x i16> %5 +} + +define <32 x i16> @concat_trunc_packusdw_512(<16 x i32> %a0, <16 x i32> %a1) nounwind { +; AVX512-LABEL: concat_trunc_packusdw_512: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsrld $17, %zmm0, %zmm0 +; AVX512-NEXT: vpsrld $23, %zmm1, %zmm1 +; AVX512-NEXT: vpmovdw %zmm0, %ymm0 +; AVX512-NEXT: vpmovdw %zmm1, %ymm1 +; AVX512-NEXT: vmovdqa {{.*#+}} ymm2 = [2,6,3,7] +; AVX512-NEXT: vpermi2q %ymm1, %ymm0, %ymm2 +; AVX512-NEXT: vmovdqa {{.*#+}} ymm3 = [0,4,1,5] +; AVX512-NEXT: vpermi2q %ymm1, %ymm0, %ymm3 +; AVX512-NEXT: vinserti64x4 $1, %ymm2, %zmm3, %zmm0 +; AVX512-NEXT: retq + %1 = lshr <16 x i32> %a0, + %2 = lshr <16 x i32> %a1, + %3 = trunc <16 x i32> %1 to <16 x i16> + %4 = trunc <16 x i32> %2 to <16 x i16> + %5 = shufflevector <16 x i16> %3, <16 x i16> %4, <32 x i32> + ret <32 x i16> %5 +} + +define <64 x i8> @concat_trunc_packsswb_512(<32 x i16> %a0, <32 x i16> %a1) nounwind { +; AVX512F-LABEL: concat_trunc_packsswb_512: +; AVX512F: # %bb.0: +; AVX512F-NEXT: vextracti64x4 $1, %zmm0, %ymm2 +; AVX512F-NEXT: vpsraw $15, %ymm2, %ymm2 +; AVX512F-NEXT: vpsraw $15, %ymm0, %ymm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm0 = ymm0[0],zero,ymm0[1],zero,ymm0[2],zero,ymm0[3],zero,ymm0[4],zero,ymm0[5],zero,ymm0[6],zero,ymm0[7],zero,ymm0[8],zero,ymm0[9],zero,ymm0[10],zero,ymm0[11],zero,ymm0[12],zero,ymm0[13],zero,ymm0[14],zero,ymm0[15],zero +; AVX512F-NEXT: vpmovdb %zmm0, %xmm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm2 = ymm2[0],zero,ymm2[1],zero,ymm2[2],zero,ymm2[3],zero,ymm2[4],zero,ymm2[5],zero,ymm2[6],zero,ymm2[7],zero,ymm2[8],zero,ymm2[9],zero,ymm2[10],zero,ymm2[11],zero,ymm2[12],zero,ymm2[13],zero,ymm2[14],zero,ymm2[15],zero +; AVX512F-NEXT: vpmovdb %zmm2, %xmm2 +; AVX512F-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm2 = ymm1[0],zero,ymm1[1],zero,ymm1[2],zero,ymm1[3],zero,ymm1[4],zero,ymm1[5],zero,ymm1[6],zero,ymm1[7],zero,ymm1[8],zero,ymm1[9],zero,ymm1[10],zero,ymm1[11],zero,ymm1[12],zero,ymm1[13],zero,ymm1[14],zero,ymm1[15],zero +; AVX512F-NEXT: vpmovdb %zmm2, %xmm2 +; AVX512F-NEXT: vextracti64x4 $1, %zmm1, %ymm1 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm1 = ymm1[0],zero,ymm1[1],zero,ymm1[2],zero,ymm1[3],zero,ymm1[4],zero,ymm1[5],zero,ymm1[6],zero,ymm1[7],zero,ymm1[8],zero,ymm1[9],zero,ymm1[10],zero,ymm1[11],zero,ymm1[12],zero,ymm1[13],zero,ymm1[14],zero,ymm1[15],zero +; AVX512F-NEXT: vpmovdb %zmm1, %xmm1 +; AVX512F-NEXT: vinserti128 $1, %xmm1, %ymm2, %ymm1 +; AVX512F-NEXT: vpand {{.*}}(%rip), %ymm1, %ymm1 +; AVX512F-NEXT: vmovdqa {{.*#+}} ymm2 = [2,6,3,7] +; AVX512F-NEXT: vpermi2q %ymm1, %ymm0, %ymm2 +; AVX512F-NEXT: vmovdqa {{.*#+}} ymm3 = [0,4,1,5] +; AVX512F-NEXT: vpermi2q %ymm1, %ymm0, %ymm3 +; AVX512F-NEXT: vinserti64x4 $1, %ymm2, %zmm3, %zmm0 +; AVX512F-NEXT: retq +; +; AVX512BW-LABEL: concat_trunc_packsswb_512: +; AVX512BW: # %bb.0: +; AVX512BW-NEXT: vpsraw $15, %zmm0, %zmm0 +; AVX512BW-NEXT: vpmovwb %zmm0, %ymm0 +; AVX512BW-NEXT: vpmovwb %zmm1, %ymm1 +; AVX512BW-NEXT: vpand {{.*}}(%rip), %ymm1, %ymm1 +; AVX512BW-NEXT: vmovdqa {{.*#+}} ymm2 = [2,6,3,7] +; AVX512BW-NEXT: vpermi2q %ymm1, %ymm0, %ymm2 +; AVX512BW-NEXT: vmovdqa {{.*#+}} ymm3 = [0,4,1,5] +; AVX512BW-NEXT: vpermi2q %ymm1, %ymm0, %ymm3 +; AVX512BW-NEXT: vinserti64x4 $1, %ymm2, %zmm3, %zmm0 +; AVX512BW-NEXT: retq + %1 = ashr <32 x i16> %a0, + %2 = and <32 x i16> %a1, + %3 = trunc <32 x i16> %1 to <32 x i8> + %4 = trunc <32 x i16> %2 to <32 x i8> + %5 = shufflevector <32 x i8> %3, <32 x i8> %4, <64 x i32> + ret <64 x i8> %5 +} + +define <64 x i8> @concat_trunc_packuswb_512(<32 x i16> %a0, <32 x i16> %a1) nounwind { +; AVX512F-LABEL: concat_trunc_packuswb_512: +; AVX512F: # %bb.0: +; AVX512F-NEXT: vextracti64x4 $1, %zmm0, %ymm2 +; AVX512F-NEXT: vpsrlw $15, %ymm2, %ymm2 +; AVX512F-NEXT: vpsrlw $15, %ymm0, %ymm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm0 = ymm0[0],zero,ymm0[1],zero,ymm0[2],zero,ymm0[3],zero,ymm0[4],zero,ymm0[5],zero,ymm0[6],zero,ymm0[7],zero,ymm0[8],zero,ymm0[9],zero,ymm0[10],zero,ymm0[11],zero,ymm0[12],zero,ymm0[13],zero,ymm0[14],zero,ymm0[15],zero +; AVX512F-NEXT: vpmovdb %zmm0, %xmm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm2 = ymm2[0],zero,ymm2[1],zero,ymm2[2],zero,ymm2[3],zero,ymm2[4],zero,ymm2[5],zero,ymm2[6],zero,ymm2[7],zero,ymm2[8],zero,ymm2[9],zero,ymm2[10],zero,ymm2[11],zero,ymm2[12],zero,ymm2[13],zero,ymm2[14],zero,ymm2[15],zero +; AVX512F-NEXT: vpmovdb %zmm2, %xmm2 +; AVX512F-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm2 = ymm1[0],zero,ymm1[1],zero,ymm1[2],zero,ymm1[3],zero,ymm1[4],zero,ymm1[5],zero,ymm1[6],zero,ymm1[7],zero,ymm1[8],zero,ymm1[9],zero,ymm1[10],zero,ymm1[11],zero,ymm1[12],zero,ymm1[13],zero,ymm1[14],zero,ymm1[15],zero +; AVX512F-NEXT: vpmovdb %zmm2, %xmm2 +; AVX512F-NEXT: vextracti64x4 $1, %zmm1, %ymm1 +; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm1 = ymm1[0],zero,ymm1[1],zero,ymm1[2],zero,ymm1[3],zero,ymm1[4],zero,ymm1[5],zero,ymm1[6],zero,ymm1[7],zero,ymm1[8],zero,ymm1[9],zero,ymm1[10],zero,ymm1[11],zero,ymm1[12],zero,ymm1[13],zero,ymm1[14],zero,ymm1[15],zero +; AVX512F-NEXT: vpmovdb %zmm1, %xmm1 +; AVX512F-NEXT: vinserti128 $1, %xmm1, %ymm2, %ymm1 +; AVX512F-NEXT: vpand {{.*}}(%rip), %ymm1, %ymm1 +; AVX512F-NEXT: vmovdqa {{.*#+}} ymm2 = [2,6,3,7] +; AVX512F-NEXT: vpermi2q %ymm1, %ymm0, %ymm2 +; AVX512F-NEXT: vmovdqa {{.*#+}} ymm3 = [0,4,1,5] +; AVX512F-NEXT: vpermi2q %ymm1, %ymm0, %ymm3 +; AVX512F-NEXT: vinserti64x4 $1, %ymm2, %zmm3, %zmm0 +; AVX512F-NEXT: retq +; +; AVX512BW-LABEL: concat_trunc_packuswb_512: +; AVX512BW: # %bb.0: +; AVX512BW-NEXT: vpsrlw $15, %zmm0, %zmm0 +; AVX512BW-NEXT: vpmovwb %zmm0, %ymm0 +; AVX512BW-NEXT: vpmovwb %zmm1, %ymm1 +; AVX512BW-NEXT: vpand {{.*}}(%rip), %ymm1, %ymm1 +; AVX512BW-NEXT: vmovdqa {{.*#+}} ymm2 = [2,6,3,7] +; AVX512BW-NEXT: vpermi2q %ymm1, %ymm0, %ymm2 +; AVX512BW-NEXT: vmovdqa {{.*#+}} ymm3 = [0,4,1,5] +; AVX512BW-NEXT: vpermi2q %ymm1, %ymm0, %ymm3 +; AVX512BW-NEXT: vinserti64x4 $1, %ymm2, %zmm3, %zmm0 +; AVX512BW-NEXT: retq + %1 = lshr <32 x i16> %a0, + %2 = and <32 x i16> %a1, + %3 = trunc <32 x i16> %1 to <32 x i8> + %4 = trunc <32 x i16> %2 to <32 x i8> + %5 = shufflevector <32 x i8> %3, <32 x i8> %4, <64 x i32> + ret <64 x i8> %5 +}