diff --git a/llvm/test/CodeGen/X86/tuning-shuffle-permilps.ll b/llvm/test/CodeGen/X86/tuning-shuffle-permilps.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/X86/tuning-shuffle-permilps.ll @@ -0,0 +1,568 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -mtriple=x86_64-unknown-unknown --mattr=+avx,+no-bypass-delay-shuffle | FileCheck %s --check-prefixes=CHECK,CHECK-AV,CHECK-AVX +; RUN: llc < %s -mtriple=x86_64-unknown-unknown --mattr=+avx2,+no-bypass-delay-shuffle | FileCheck %s --check-prefixes=CHECK,CHECK-AV,CHECK-AVX2 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=icelake-server | FileCheck %s --check-prefixes=CHECK,CHECK-512,CHECK-ICX +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64-v4 | FileCheck %s --check-prefixes=CHECK,CHECK-512,CHECK-V4 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=znver4 | FileCheck %s --check-prefixes=CHECK,CHECK-512,CHECK-ZNVER4 + +define <16 x float> @transform_VPERMILPSZrr(<16 x float> %a) nounwind { +; CHECK-AV-LABEL: transform_VPERMILPSZrr: +; CHECK-AV: # %bb.0: +; CHECK-AV-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4] +; CHECK-AV-NEXT: vpermilps {{.*#+}} ymm1 = ymm1[3,2,1,0,7,6,5,4] +; CHECK-AV-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSZrr: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: vpermilps {{.*#+}} zmm0 = zmm0[3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12] +; CHECK-512-NEXT: retq + %shufp = shufflevector <16 x float> %a, <16 x float> poison, <16 x i32> + ret <16 x float> %shufp +} + +define <8 x float> @transform_VPERMILPSYrr(<8 x float> %a) nounwind { +; CHECK-LABEL: transform_VPERMILPSYrr: +; CHECK: # %bb.0: +; CHECK-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4] +; CHECK-NEXT: retq + %shufp = shufflevector <8 x float> %a, <8 x float> poison, <8 x i32> + ret <8 x float> %shufp +} + +define <4 x float> @transform_VPERMILPSrr(<4 x float> %a) nounwind { +; CHECK-LABEL: transform_VPERMILPSrr: +; CHECK: # %bb.0: +; CHECK-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[3,2,1,0] +; CHECK-NEXT: retq + %shufp = shufflevector <4 x float> %a, <4 x float> poison, <4 x i32> + ret <4 x float> %shufp +} + +define <16 x float> @transform_VPERMILPSZrrkz(<16 x float> %a, i16 %mask_int) nounwind { +; CHECK-AVX-LABEL: transform_VPERMILPSZrrkz: +; CHECK-AVX: # %bb.0: +; CHECK-AVX-NEXT: vpermilps {{.*#+}} ymm1 = ymm1[3,2,1,0,7,6,5,4] +; CHECK-AVX-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4] +; CHECK-AVX-NEXT: vmovd %edi, %xmm2 +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm2 = xmm2[0,0,0,0] +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm2, %ymm2, %ymm2 +; CHECK-AVX-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm2, %ymm3 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm3, %xmm4 +; CHECK-AVX-NEXT: vextractf128 $1, %ymm3, %xmm3 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm3, %xmm3 +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm3, %ymm4, %ymm3 +; CHECK-AVX-NEXT: vandps %ymm0, %ymm3, %ymm0 +; CHECK-AVX-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm2, %ymm2 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm3 +; CHECK-AVX-NEXT: vextractf128 $1, %ymm2, %xmm2 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm2 +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm2, %ymm3, %ymm2 +; CHECK-AVX-NEXT: vandps %ymm1, %ymm2, %ymm1 +; CHECK-AVX-NEXT: retq +; +; CHECK-AVX2-LABEL: transform_VPERMILPSZrrkz: +; CHECK-AVX2: # %bb.0: +; CHECK-AVX2-NEXT: vpshufd {{.*#+}} ymm1 = ymm1[3,2,1,0,7,6,5,4] +; CHECK-AVX2-NEXT: vpshufd {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4] +; CHECK-AVX2-NEXT: vmovd %edi, %xmm2 +; CHECK-AVX2-NEXT: vpbroadcastw %xmm2, %ymm2 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} ymm3 = [1,2,4,8,16,32,64,128] +; CHECK-AVX2-NEXT: vpand %ymm3, %ymm2, %ymm4 +; CHECK-AVX2-NEXT: vpcmpeqd %ymm3, %ymm4, %ymm3 +; CHECK-AVX2-NEXT: vpand %ymm0, %ymm3, %ymm0 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} ymm3 = [256,512,1024,2048,4096,8192,16384,32768] +; CHECK-AVX2-NEXT: vpand %ymm3, %ymm2, %ymm2 +; CHECK-AVX2-NEXT: vpcmpeqd %ymm3, %ymm2, %ymm2 +; CHECK-AVX2-NEXT: vpand %ymm1, %ymm2, %ymm1 +; CHECK-AVX2-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSZrrkz: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: kmovd %edi, %k1 +; CHECK-512-NEXT: vpermilps {{.*#+}} zmm0 {%k1} {z} = zmm0[3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12] +; CHECK-512-NEXT: retq + %mask = bitcast i16 %mask_int to <16 x i1> + %shufp = shufflevector <16 x float> %a, <16 x float> poison, <16 x i32> + %res = select <16 x i1> %mask, <16 x float> %shufp, <16 x float> zeroinitializer + ret <16 x float> %res +} + +define <8 x float> @transform_VPERMILPSYrrkz(<8 x float> %a, i8 %mask_int) nounwind { +; CHECK-AVX-LABEL: transform_VPERMILPSYrrkz: +; CHECK-AVX: # %bb.0: +; CHECK-AVX-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4] +; CHECK-AVX-NEXT: vmovd %edi, %xmm1 +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm1 = xmm1[0,0,0,0] +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm1, %ymm1, %ymm1 +; CHECK-AVX-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm1 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm2 +; CHECK-AVX-NEXT: vextractf128 $1, %ymm1, %xmm1 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1 +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm1, %ymm2, %ymm1 +; CHECK-AVX-NEXT: vandps %ymm0, %ymm1, %ymm0 +; CHECK-AVX-NEXT: retq +; +; CHECK-AVX2-LABEL: transform_VPERMILPSYrrkz: +; CHECK-AVX2: # %bb.0: +; CHECK-AVX2-NEXT: vpshufd {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4] +; CHECK-AVX2-NEXT: vmovd %edi, %xmm1 +; CHECK-AVX2-NEXT: vpbroadcastb %xmm1, %ymm1 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} ymm2 = [1,2,4,8,16,32,64,128] +; CHECK-AVX2-NEXT: vpand %ymm2, %ymm1, %ymm1 +; CHECK-AVX2-NEXT: vpcmpeqd %ymm2, %ymm1, %ymm1 +; CHECK-AVX2-NEXT: vpand %ymm0, %ymm1, %ymm0 +; CHECK-AVX2-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSYrrkz: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: kmovd %edi, %k1 +; CHECK-512-NEXT: vpermilps {{.*#+}} ymm0 {%k1} {z} = ymm0[3,2,1,0,7,6,5,4] +; CHECK-512-NEXT: retq + %mask = bitcast i8 %mask_int to <8 x i1> + %shufp = shufflevector <8 x float> %a, <8 x float> poison, <8 x i32> + %res = select <8 x i1> %mask, <8 x float> %shufp, <8 x float> zeroinitializer + ret <8 x float> %res +} + +define <4 x float> @transform_VPERMILPSrrkz(<4 x float> %a, i4 %mask_int) nounwind { +; CHECK-AVX-LABEL: transform_VPERMILPSrrkz: +; CHECK-AVX: # %bb.0: +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[3,2,1,0] +; CHECK-AVX-NEXT: vmovd %edi, %xmm1 +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm1 = xmm1[0,0,0,0] +; CHECK-AVX-NEXT: vmovdqa {{.*#+}} xmm2 = [1,2,4,8] +; CHECK-AVX-NEXT: vpand %xmm2, %xmm1, %xmm1 +; CHECK-AVX-NEXT: vpcmpeqd %xmm2, %xmm1, %xmm1 +; CHECK-AVX-NEXT: vpand %xmm0, %xmm1, %xmm0 +; CHECK-AVX-NEXT: retq +; +; CHECK-AVX2-LABEL: transform_VPERMILPSrrkz: +; CHECK-AVX2: # %bb.0: +; CHECK-AVX2-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[3,2,1,0] +; CHECK-AVX2-NEXT: vmovd %edi, %xmm1 +; CHECK-AVX2-NEXT: vpbroadcastd %xmm1, %xmm1 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} xmm2 = [1,2,4,8] +; CHECK-AVX2-NEXT: vpand %xmm2, %xmm1, %xmm1 +; CHECK-AVX2-NEXT: vpcmpeqd %xmm2, %xmm1, %xmm1 +; CHECK-AVX2-NEXT: vpand %xmm0, %xmm1, %xmm0 +; CHECK-AVX2-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSrrkz: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: kmovd %edi, %k1 +; CHECK-512-NEXT: vpermilps {{.*#+}} xmm0 {%k1} {z} = xmm0[3,2,1,0] +; CHECK-512-NEXT: retq + %mask = bitcast i4 %mask_int to <4 x i1> + %shufp = shufflevector <4 x float> %a, <4 x float> poison, <4 x i32> + %res = select <4 x i1> %mask, <4 x float> %shufp, <4 x float> zeroinitializer + ret <4 x float> %res +} + +define <16 x float> @transform_VPERMILPSZrrk(<16 x float> %a, <16 x float> %b, i16 %mask_int) nounwind { +; CHECK-AVX-LABEL: transform_VPERMILPSZrrk: +; CHECK-AVX: # %bb.0: +; CHECK-AVX-NEXT: vpermilps {{.*#+}} ymm1 = ymm1[3,2,1,0,7,6,5,4] +; CHECK-AVX-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4] +; CHECK-AVX-NEXT: vmovd %edi, %xmm4 +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm4 = xmm4[0,0,0,0] +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm4, %ymm4, %ymm4 +; CHECK-AVX-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm4, %ymm5 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm5, %xmm6 +; CHECK-AVX-NEXT: vextractf128 $1, %ymm5, %xmm5 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm5, %xmm5 +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm5, %ymm6, %ymm5 +; CHECK-AVX-NEXT: vblendvps %ymm5, %ymm0, %ymm2, %ymm0 +; CHECK-AVX-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm4, %ymm2 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm4 +; CHECK-AVX-NEXT: vextractf128 $1, %ymm2, %xmm2 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm2 +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm2, %ymm4, %ymm2 +; CHECK-AVX-NEXT: vblendvps %ymm2, %ymm1, %ymm3, %ymm1 +; CHECK-AVX-NEXT: retq +; +; CHECK-AVX2-LABEL: transform_VPERMILPSZrrk: +; CHECK-AVX2: # %bb.0: +; CHECK-AVX2-NEXT: vpermilps {{.*#+}} ymm1 = ymm1[3,2,1,0,7,6,5,4] +; CHECK-AVX2-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4] +; CHECK-AVX2-NEXT: vmovd %edi, %xmm4 +; CHECK-AVX2-NEXT: vpbroadcastw %xmm4, %ymm4 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} ymm5 = [1,2,4,8,16,32,64,128] +; CHECK-AVX2-NEXT: vpand %ymm5, %ymm4, %ymm6 +; CHECK-AVX2-NEXT: vpcmpeqd %ymm5, %ymm6, %ymm5 +; CHECK-AVX2-NEXT: vblendvps %ymm5, %ymm0, %ymm2, %ymm0 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} ymm2 = [256,512,1024,2048,4096,8192,16384,32768] +; CHECK-AVX2-NEXT: vpand %ymm2, %ymm4, %ymm4 +; CHECK-AVX2-NEXT: vpcmpeqd %ymm2, %ymm4, %ymm2 +; CHECK-AVX2-NEXT: vblendvps %ymm2, %ymm1, %ymm3, %ymm1 +; CHECK-AVX2-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSZrrk: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: kmovd %edi, %k1 +; CHECK-512-NEXT: vpermilps {{.*#+}} zmm1 {%k1} = zmm0[3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12] +; CHECK-512-NEXT: vmovaps %zmm1, %zmm0 +; CHECK-512-NEXT: retq + %mask = bitcast i16 %mask_int to <16 x i1> + %shufp = shufflevector <16 x float> %a, <16 x float> poison, <16 x i32> + %res = select <16 x i1> %mask, <16 x float> %shufp, <16 x float> %b + ret <16 x float> %res +} + +define <8 x float> @transform_VPERMILPSYrrk(<8 x float> %a, <8 x float> %b, i8 %mask_int) nounwind { +; CHECK-AVX-LABEL: transform_VPERMILPSYrrk: +; CHECK-AVX: # %bb.0: +; CHECK-AVX-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4] +; CHECK-AVX-NEXT: vmovd %edi, %xmm2 +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm2 = xmm2[0,0,0,0] +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm2, %ymm2, %ymm2 +; CHECK-AVX-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm2, %ymm2 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm3 +; CHECK-AVX-NEXT: vextractf128 $1, %ymm2, %xmm2 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm2 +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm2, %ymm3, %ymm2 +; CHECK-AVX-NEXT: vblendvps %ymm2, %ymm0, %ymm1, %ymm0 +; CHECK-AVX-NEXT: retq +; +; CHECK-AVX2-LABEL: transform_VPERMILPSYrrk: +; CHECK-AVX2: # %bb.0: +; CHECK-AVX2-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4] +; CHECK-AVX2-NEXT: vmovd %edi, %xmm2 +; CHECK-AVX2-NEXT: vpbroadcastb %xmm2, %ymm2 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} ymm3 = [1,2,4,8,16,32,64,128] +; CHECK-AVX2-NEXT: vpand %ymm3, %ymm2, %ymm2 +; CHECK-AVX2-NEXT: vpcmpeqd %ymm3, %ymm2, %ymm2 +; CHECK-AVX2-NEXT: vblendvps %ymm2, %ymm0, %ymm1, %ymm0 +; CHECK-AVX2-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSYrrk: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: kmovd %edi, %k1 +; CHECK-512-NEXT: vpermilps {{.*#+}} ymm1 {%k1} = ymm0[3,2,1,0,7,6,5,4] +; CHECK-512-NEXT: vmovaps %ymm1, %ymm0 +; CHECK-512-NEXT: retq + %mask = bitcast i8 %mask_int to <8 x i1> + %shufp = shufflevector <8 x float> %a, <8 x float> poison, <8 x i32> + %res = select <8 x i1> %mask, <8 x float> %shufp, <8 x float> %b + ret <8 x float> %res +} + +define <4 x float> @transform_VPERMILPSrrk(<4 x float> %a, <4 x float> %b, i4 %mask_int) nounwind { +; CHECK-AVX-LABEL: transform_VPERMILPSrrk: +; CHECK-AVX: # %bb.0: +; CHECK-AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[3,2,1,0] +; CHECK-AVX-NEXT: vmovd %edi, %xmm2 +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm2 = xmm2[0,0,0,0] +; CHECK-AVX-NEXT: vmovdqa {{.*#+}} xmm3 = [1,2,4,8] +; CHECK-AVX-NEXT: vpand %xmm3, %xmm2, %xmm2 +; CHECK-AVX-NEXT: vpcmpeqd %xmm3, %xmm2, %xmm2 +; CHECK-AVX-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0 +; CHECK-AVX-NEXT: retq +; +; CHECK-AVX2-LABEL: transform_VPERMILPSrrk: +; CHECK-AVX2: # %bb.0: +; CHECK-AVX2-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[3,2,1,0] +; CHECK-AVX2-NEXT: vmovd %edi, %xmm2 +; CHECK-AVX2-NEXT: vpbroadcastd %xmm2, %xmm2 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} xmm3 = [1,2,4,8] +; CHECK-AVX2-NEXT: vpand %xmm3, %xmm2, %xmm2 +; CHECK-AVX2-NEXT: vpcmpeqd %xmm3, %xmm2, %xmm2 +; CHECK-AVX2-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0 +; CHECK-AVX2-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSrrk: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: kmovd %edi, %k1 +; CHECK-512-NEXT: vpermilps {{.*#+}} xmm1 {%k1} = xmm0[3,2,1,0] +; CHECK-512-NEXT: vmovaps %xmm1, %xmm0 +; CHECK-512-NEXT: retq + %mask = bitcast i4 %mask_int to <4 x i1> + %shufp = shufflevector <4 x float> %a, <4 x float> poison, <4 x i32> + %res = select <4 x i1> %mask, <4 x float> %shufp, <4 x float> %b + ret <4 x float> %res +} + +define <16 x float> @transform_VPERMILPSZrm(ptr %ap) nounwind { +; CHECK-AV-LABEL: transform_VPERMILPSZrm: +; CHECK-AV: # %bb.0: +; CHECK-AV-NEXT: vpermilps {{.*#+}} ymm0 = mem[3,2,1,0,7,6,5,4] +; CHECK-AV-NEXT: vpermilps {{.*#+}} ymm1 = mem[3,2,1,0,7,6,5,4] +; CHECK-AV-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSZrm: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: vpermilps {{.*#+}} zmm0 = mem[3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12] +; CHECK-512-NEXT: retq + %a = load <16 x float>, ptr %ap + %shufp = shufflevector <16 x float> %a, <16 x float> poison, <16 x i32> + ret <16 x float> %shufp +} + +define <8 x float> @transform_VPERMILPSYrm(ptr %ap) nounwind { +; CHECK-LABEL: transform_VPERMILPSYrm: +; CHECK: # %bb.0: +; CHECK-NEXT: vpermilps {{.*#+}} ymm0 = mem[3,2,1,0,7,6,5,4] +; CHECK-NEXT: retq + %a = load <8 x float>, ptr %ap + %shufp = shufflevector <8 x float> %a, <8 x float> poison, <8 x i32> + ret <8 x float> %shufp +} + +define <4 x float> @transform_VPERMILPSrm(ptr %ap) nounwind { +; CHECK-LABEL: transform_VPERMILPSrm: +; CHECK: # %bb.0: +; CHECK-NEXT: vpermilps {{.*#+}} xmm0 = mem[3,2,1,0] +; CHECK-NEXT: retq + %a = load <4 x float>, ptr %ap + %shufp = shufflevector <4 x float> %a, <4 x float> poison, <4 x i32> + ret <4 x float> %shufp +} + +define <16 x float> @transform_VPERMILPSZrmkz(ptr %ap, i16 %mask_int) nounwind { +; CHECK-AVX-LABEL: transform_VPERMILPSZrmkz: +; CHECK-AVX: # %bb.0: +; CHECK-AVX-NEXT: vpermilps {{.*#+}} ymm1 = mem[3,2,1,0,7,6,5,4] +; CHECK-AVX-NEXT: vpermilps {{.*#+}} ymm0 = mem[3,2,1,0,7,6,5,4] +; CHECK-AVX-NEXT: vmovd %esi, %xmm2 +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm2 = xmm2[0,0,0,0] +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm2, %ymm2, %ymm2 +; CHECK-AVX-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm2, %ymm3 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm3, %xmm4 +; CHECK-AVX-NEXT: vextractf128 $1, %ymm3, %xmm3 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm3, %xmm3 +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm3, %ymm4, %ymm3 +; CHECK-AVX-NEXT: vandps %ymm0, %ymm3, %ymm0 +; CHECK-AVX-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm2, %ymm2 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm3 +; CHECK-AVX-NEXT: vextractf128 $1, %ymm2, %xmm2 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm2 +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm2, %ymm3, %ymm2 +; CHECK-AVX-NEXT: vandps %ymm1, %ymm2, %ymm1 +; CHECK-AVX-NEXT: retq +; +; CHECK-AVX2-LABEL: transform_VPERMILPSZrmkz: +; CHECK-AVX2: # %bb.0: +; CHECK-AVX2-NEXT: vpshufd {{.*#+}} ymm1 = mem[3,2,1,0,7,6,5,4] +; CHECK-AVX2-NEXT: vpshufd {{.*#+}} ymm0 = mem[3,2,1,0,7,6,5,4] +; CHECK-AVX2-NEXT: vmovd %esi, %xmm2 +; CHECK-AVX2-NEXT: vpbroadcastw %xmm2, %ymm2 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} ymm3 = [1,2,4,8,16,32,64,128] +; CHECK-AVX2-NEXT: vpand %ymm3, %ymm2, %ymm4 +; CHECK-AVX2-NEXT: vpcmpeqd %ymm3, %ymm4, %ymm3 +; CHECK-AVX2-NEXT: vpand %ymm0, %ymm3, %ymm0 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} ymm3 = [256,512,1024,2048,4096,8192,16384,32768] +; CHECK-AVX2-NEXT: vpand %ymm3, %ymm2, %ymm2 +; CHECK-AVX2-NEXT: vpcmpeqd %ymm3, %ymm2, %ymm2 +; CHECK-AVX2-NEXT: vpand %ymm1, %ymm2, %ymm1 +; CHECK-AVX2-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSZrmkz: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: kmovd %esi, %k1 +; CHECK-512-NEXT: vpermilps {{.*#+}} zmm0 {%k1} {z} = mem[3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12] +; CHECK-512-NEXT: retq + %mask = bitcast i16 %mask_int to <16 x i1> + %a = load <16 x float>, ptr %ap + %shufp = shufflevector <16 x float> %a, <16 x float> poison, <16 x i32> + %res = select <16 x i1> %mask, <16 x float> %shufp, <16 x float> zeroinitializer + ret <16 x float> %res +} + +define <8 x float> @transform_VPERMILPSYrmkz(ptr %ap, i8 %mask_int) nounwind { +; CHECK-AVX-LABEL: transform_VPERMILPSYrmkz: +; CHECK-AVX: # %bb.0: +; CHECK-AVX-NEXT: vpermilps {{.*#+}} ymm0 = mem[3,2,1,0,7,6,5,4] +; CHECK-AVX-NEXT: vmovd %esi, %xmm1 +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm1 = xmm1[0,0,0,0] +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm1, %ymm1, %ymm1 +; CHECK-AVX-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm1 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm2 +; CHECK-AVX-NEXT: vextractf128 $1, %ymm1, %xmm1 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1 +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm1, %ymm2, %ymm1 +; CHECK-AVX-NEXT: vandps %ymm0, %ymm1, %ymm0 +; CHECK-AVX-NEXT: retq +; +; CHECK-AVX2-LABEL: transform_VPERMILPSYrmkz: +; CHECK-AVX2: # %bb.0: +; CHECK-AVX2-NEXT: vpshufd {{.*#+}} ymm0 = mem[3,2,1,0,7,6,5,4] +; CHECK-AVX2-NEXT: vmovd %esi, %xmm1 +; CHECK-AVX2-NEXT: vpbroadcastb %xmm1, %ymm1 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} ymm2 = [1,2,4,8,16,32,64,128] +; CHECK-AVX2-NEXT: vpand %ymm2, %ymm1, %ymm1 +; CHECK-AVX2-NEXT: vpcmpeqd %ymm2, %ymm1, %ymm1 +; CHECK-AVX2-NEXT: vpand %ymm0, %ymm1, %ymm0 +; CHECK-AVX2-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSYrmkz: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: kmovd %esi, %k1 +; CHECK-512-NEXT: vpermilps {{.*#+}} ymm0 {%k1} {z} = mem[3,2,1,0,7,6,5,4] +; CHECK-512-NEXT: retq + %mask = bitcast i8 %mask_int to <8 x i1> + %a = load <8 x float>, ptr %ap + %shufp = shufflevector <8 x float> %a, <8 x float> poison, <8 x i32> + %res = select <8 x i1> %mask, <8 x float> %shufp, <8 x float> zeroinitializer + ret <8 x float> %res +} + +define <4 x float> @transform_VPERMILPSrmkz(ptr %ap, i4 %mask_int) nounwind { +; CHECK-AVX-LABEL: transform_VPERMILPSrmkz: +; CHECK-AVX: # %bb.0: +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm0 = mem[3,2,1,0] +; CHECK-AVX-NEXT: vmovd %esi, %xmm1 +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm1 = xmm1[0,0,0,0] +; CHECK-AVX-NEXT: vmovdqa {{.*#+}} xmm2 = [1,2,4,8] +; CHECK-AVX-NEXT: vpand %xmm2, %xmm1, %xmm1 +; CHECK-AVX-NEXT: vpcmpeqd %xmm2, %xmm1, %xmm1 +; CHECK-AVX-NEXT: vpand %xmm0, %xmm1, %xmm0 +; CHECK-AVX-NEXT: retq +; +; CHECK-AVX2-LABEL: transform_VPERMILPSrmkz: +; CHECK-AVX2: # %bb.0: +; CHECK-AVX2-NEXT: vpshufd {{.*#+}} xmm0 = mem[3,2,1,0] +; CHECK-AVX2-NEXT: vmovd %esi, %xmm1 +; CHECK-AVX2-NEXT: vpbroadcastd %xmm1, %xmm1 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} xmm2 = [1,2,4,8] +; CHECK-AVX2-NEXT: vpand %xmm2, %xmm1, %xmm1 +; CHECK-AVX2-NEXT: vpcmpeqd %xmm2, %xmm1, %xmm1 +; CHECK-AVX2-NEXT: vpand %xmm0, %xmm1, %xmm0 +; CHECK-AVX2-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSrmkz: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: kmovd %esi, %k1 +; CHECK-512-NEXT: vpermilps {{.*#+}} xmm0 {%k1} {z} = mem[3,2,1,0] +; CHECK-512-NEXT: retq + %mask = bitcast i4 %mask_int to <4 x i1> + %a = load <4 x float>, ptr %ap + %shufp = shufflevector <4 x float> %a, <4 x float> poison, <4 x i32> + %res = select <4 x i1> %mask, <4 x float> %shufp, <4 x float> zeroinitializer + ret <4 x float> %res +} + +define <16 x float> @transform_VPERMILPSZrmk(ptr %ap, <16 x float> %b, i16 %mask_int) nounwind { +; CHECK-AVX-LABEL: transform_VPERMILPSZrmk: +; CHECK-AVX: # %bb.0: +; CHECK-AVX-NEXT: vpermilps {{.*#+}} ymm2 = mem[3,2,1,0,7,6,5,4] +; CHECK-AVX-NEXT: vpermilps {{.*#+}} ymm3 = mem[3,2,1,0,7,6,5,4] +; CHECK-AVX-NEXT: vmovd %esi, %xmm4 +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm4 = xmm4[0,0,0,0] +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm4, %ymm4, %ymm4 +; CHECK-AVX-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm4, %ymm5 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm5, %xmm6 +; CHECK-AVX-NEXT: vextractf128 $1, %ymm5, %xmm5 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm5, %xmm5 +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm5, %ymm6, %ymm5 +; CHECK-AVX-NEXT: vblendvps %ymm5, %ymm3, %ymm0, %ymm0 +; CHECK-AVX-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm4, %ymm3 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm3, %xmm4 +; CHECK-AVX-NEXT: vextractf128 $1, %ymm3, %xmm3 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm3, %xmm3 +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm3, %ymm4, %ymm3 +; CHECK-AVX-NEXT: vblendvps %ymm3, %ymm2, %ymm1, %ymm1 +; CHECK-AVX-NEXT: retq +; +; CHECK-AVX2-LABEL: transform_VPERMILPSZrmk: +; CHECK-AVX2: # %bb.0: +; CHECK-AVX2-NEXT: vpermilps {{.*#+}} ymm2 = mem[3,2,1,0,7,6,5,4] +; CHECK-AVX2-NEXT: vpermilps {{.*#+}} ymm3 = mem[3,2,1,0,7,6,5,4] +; CHECK-AVX2-NEXT: vmovd %esi, %xmm4 +; CHECK-AVX2-NEXT: vpbroadcastw %xmm4, %ymm4 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} ymm5 = [1,2,4,8,16,32,64,128] +; CHECK-AVX2-NEXT: vpand %ymm5, %ymm4, %ymm6 +; CHECK-AVX2-NEXT: vpcmpeqd %ymm5, %ymm6, %ymm5 +; CHECK-AVX2-NEXT: vblendvps %ymm5, %ymm3, %ymm0, %ymm0 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} ymm3 = [256,512,1024,2048,4096,8192,16384,32768] +; CHECK-AVX2-NEXT: vpand %ymm3, %ymm4, %ymm4 +; CHECK-AVX2-NEXT: vpcmpeqd %ymm3, %ymm4, %ymm3 +; CHECK-AVX2-NEXT: vblendvps %ymm3, %ymm2, %ymm1, %ymm1 +; CHECK-AVX2-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSZrmk: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: kmovd %esi, %k1 +; CHECK-512-NEXT: vpermilps {{.*#+}} zmm0 {%k1} = mem[3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12] +; CHECK-512-NEXT: retq + %mask = bitcast i16 %mask_int to <16 x i1> + %a = load <16 x float>, ptr %ap + %shufp = shufflevector <16 x float> %a, <16 x float> poison, <16 x i32> + %res = select <16 x i1> %mask, <16 x float> %shufp, <16 x float> %b + ret <16 x float> %res +} + +define <8 x float> @transform_VPERMILPSYrmk(ptr %ap, <8 x float> %b, i8 %mask_int) nounwind { +; CHECK-AVX-LABEL: transform_VPERMILPSYrmk: +; CHECK-AVX: # %bb.0: +; CHECK-AVX-NEXT: vpermilps {{.*#+}} ymm1 = mem[3,2,1,0,7,6,5,4] +; CHECK-AVX-NEXT: vmovd %esi, %xmm2 +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm2 = xmm2[0,0,0,0] +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm2, %ymm2, %ymm2 +; CHECK-AVX-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm2, %ymm2 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm3 +; CHECK-AVX-NEXT: vextractf128 $1, %ymm2, %xmm2 +; CHECK-AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm2 +; CHECK-AVX-NEXT: vinsertf128 $1, %xmm2, %ymm3, %ymm2 +; CHECK-AVX-NEXT: vblendvps %ymm2, %ymm1, %ymm0, %ymm0 +; CHECK-AVX-NEXT: retq +; +; CHECK-AVX2-LABEL: transform_VPERMILPSYrmk: +; CHECK-AVX2: # %bb.0: +; CHECK-AVX2-NEXT: vpermilps {{.*#+}} ymm1 = mem[3,2,1,0,7,6,5,4] +; CHECK-AVX2-NEXT: vmovd %esi, %xmm2 +; CHECK-AVX2-NEXT: vpbroadcastb %xmm2, %ymm2 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} ymm3 = [1,2,4,8,16,32,64,128] +; CHECK-AVX2-NEXT: vpand %ymm3, %ymm2, %ymm2 +; CHECK-AVX2-NEXT: vpcmpeqd %ymm3, %ymm2, %ymm2 +; CHECK-AVX2-NEXT: vblendvps %ymm2, %ymm1, %ymm0, %ymm0 +; CHECK-AVX2-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSYrmk: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: kmovd %esi, %k1 +; CHECK-512-NEXT: vpermilps {{.*#+}} ymm0 {%k1} = mem[3,2,1,0,7,6,5,4] +; CHECK-512-NEXT: retq + %mask = bitcast i8 %mask_int to <8 x i1> + %a = load <8 x float>, ptr %ap + %shufp = shufflevector <8 x float> %a, <8 x float> poison, <8 x i32> + %res = select <8 x i1> %mask, <8 x float> %shufp, <8 x float> %b + ret <8 x float> %res +} + +define <4 x float> @transform_VPERMILPSrmk(ptr %ap, <4 x float> %b, i4 %mask_int) nounwind { +; CHECK-AVX-LABEL: transform_VPERMILPSrmk: +; CHECK-AVX: # %bb.0: +; CHECK-AVX-NEXT: vpermilps {{.*#+}} xmm1 = mem[3,2,1,0] +; CHECK-AVX-NEXT: vmovd %esi, %xmm2 +; CHECK-AVX-NEXT: vpshufd {{.*#+}} xmm2 = xmm2[0,0,0,0] +; CHECK-AVX-NEXT: vmovdqa {{.*#+}} xmm3 = [1,2,4,8] +; CHECK-AVX-NEXT: vpand %xmm3, %xmm2, %xmm2 +; CHECK-AVX-NEXT: vpcmpeqd %xmm3, %xmm2, %xmm2 +; CHECK-AVX-NEXT: vblendvps %xmm2, %xmm1, %xmm0, %xmm0 +; CHECK-AVX-NEXT: retq +; +; CHECK-AVX2-LABEL: transform_VPERMILPSrmk: +; CHECK-AVX2: # %bb.0: +; CHECK-AVX2-NEXT: vpermilps {{.*#+}} xmm1 = mem[3,2,1,0] +; CHECK-AVX2-NEXT: vmovd %esi, %xmm2 +; CHECK-AVX2-NEXT: vpbroadcastd %xmm2, %xmm2 +; CHECK-AVX2-NEXT: vmovdqa {{.*#+}} xmm3 = [1,2,4,8] +; CHECK-AVX2-NEXT: vpand %xmm3, %xmm2, %xmm2 +; CHECK-AVX2-NEXT: vpcmpeqd %xmm3, %xmm2, %xmm2 +; CHECK-AVX2-NEXT: vblendvps %xmm2, %xmm1, %xmm0, %xmm0 +; CHECK-AVX2-NEXT: retq +; +; CHECK-512-LABEL: transform_VPERMILPSrmk: +; CHECK-512: # %bb.0: +; CHECK-512-NEXT: kmovd %esi, %k1 +; CHECK-512-NEXT: vpermilps {{.*#+}} xmm0 {%k1} = mem[3,2,1,0] +; CHECK-512-NEXT: retq + %mask = bitcast i4 %mask_int to <4 x i1> + %a = load <4 x float>, ptr %ap + %shufp = shufflevector <4 x float> %a, <4 x float> poison, <4 x i32> + %res = select <4 x i1> %mask, <4 x float> %shufp, <4 x float> %b + ret <4 x float> %res +} +;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: +; CHECK-ICX: {{.*}} +; CHECK-V4: {{.*}} +; CHECK-ZNVER4: {{.*}}