1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx,+xop | FileCheck %s --check-prefixes=CHECK,X86 3; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx,+xop | FileCheck %s --check-prefixes=CHECK,X64 4 5; 6; VPPERM 7; 8 9define <16 x i8> @vpperm_shuffle_unary(<16 x i8> %a0) { 10; CHECK-LABEL: vpperm_shuffle_unary: 11; CHECK: # %bb.0: 12; CHECK-NEXT: vpperm {{.*#+}} xmm0 = xmm0[15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0] 13; CHECK-NEXT: ret{{[l|q]}} 14 %1 = tail call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> %a0, <16 x i8> <i8 31, i8 14, i8 29, i8 12, i8 27, i8 10, i8 25, i8 8, i8 23, i8 6, i8 21, i8 4, i8 19, i8 2, i8 17, i8 0>) 15 ret <16 x i8> %1 16} 17 18define <16 x i8> @vpperm_shuffle_unary_undef(<16 x i8> %a0) { 19; CHECK-LABEL: vpperm_shuffle_unary_undef: 20; CHECK: # %bb.0: 21; CHECK-NEXT: vpperm {{.*#+}} xmm0 = xmm0[15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0] 22; CHECK-NEXT: ret{{[l|q]}} 23 %1 = tail call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> undef, <16 x i8> <i8 31, i8 14, i8 29, i8 12, i8 27, i8 10, i8 25, i8 8, i8 23, i8 6, i8 21, i8 4, i8 19, i8 2, i8 17, i8 0>) 24 ret <16 x i8> %1 25} 26 27define <16 x i8> @vpperm_shuffle_unary_zero(<16 x i8> %a0) { 28; CHECK-LABEL: vpperm_shuffle_unary_zero: 29; CHECK: # %bb.0: 30; CHECK-NEXT: vpperm {{.*#+}} xmm0 = xmm0[15,14,13,12,11,10,9,8,7,6,5,4,3],zero,xmm0[1],zero 31; CHECK-NEXT: ret{{[l|q]}} 32 %1 = tail call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> %a0, <16 x i8> <i8 31, i8 14, i8 29, i8 12, i8 27, i8 10, i8 25, i8 8, i8 23, i8 6, i8 21, i8 4, i8 19, i8 130, i8 17, i8 128>) 33 ret <16 x i8> %1 34} 35 36define <16 x i8> @vpperm_shuffle_binary(<16 x i8> %a0, <16 x i8> %a1) { 37; CHECK-LABEL: vpperm_shuffle_binary: 38; CHECK: # %bb.0: 39; CHECK-NEXT: vpperm {{.*#+}} xmm0 = xmm1[15],xmm0[14],xmm1[13],xmm0[12],xmm1[11],xmm0[10],xmm1[9],xmm0[8],xmm1[7],xmm0[6],xmm1[5],xmm0[4],xmm1[3],xmm0[2],xmm1[1],xmm0[0] 40; CHECK-NEXT: ret{{[l|q]}} 41 %1 = tail call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> %a1, <16 x i8> <i8 31, i8 14, i8 29, i8 12, i8 27, i8 10, i8 25, i8 8, i8 23, i8 6, i8 21, i8 4, i8 19, i8 2, i8 17, i8 0>) 42 ret <16 x i8> %1 43} 44 45define <16 x i8> @vpperm_shuffle_binary_zero(<16 x i8> %a0, <16 x i8> %a1) { 46; CHECK-LABEL: vpperm_shuffle_binary_zero: 47; CHECK: # %bb.0: 48; CHECK-NEXT: vpperm {{.*#+}} xmm0 = xmm1[15],xmm0[14],xmm1[13],xmm0[12],xmm1[11],xmm0[10],xmm1[9],xmm0[8],xmm1[7],xmm0[6],xmm1[5],xmm0[4],zero,zero,zero,zero 49; CHECK-NEXT: ret{{[l|q]}} 50 %1 = tail call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> %a1, <16 x i8> <i8 31, i8 14, i8 29, i8 12, i8 27, i8 10, i8 25, i8 8, i8 23, i8 6, i8 21, i8 4, i8 147, i8 130, i8 145, i8 128>) 51 ret <16 x i8> %1 52} 53 54; we can't decode vpperm's other permute ops 55define <16 x i8> @vpperm_shuffle_general(<16 x i8> %a0, <16 x i8> %a1) { 56; X86-LABEL: vpperm_shuffle_general: 57; X86: # %bb.0: 58; X86-NEXT: vpperm {{\.LCPI.*}}, %xmm0, %xmm0, %xmm0 59; X86-NEXT: retl 60; 61; X64-LABEL: vpperm_shuffle_general: 62; X64: # %bb.0: 63; X64-NEXT: vpperm {{.*}}(%rip), %xmm0, %xmm0, %xmm0 64; X64-NEXT: retq 65 %1 = tail call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> %a0, <16 x i8> <i8 31, i8 14, i8 29, i8 12, i8 27, i8 10, i8 25, i8 8, i8 23, i8 6, i8 21, i8 4, i8 179, i8 162, i8 177, i8 160>) 66 ret <16 x i8> %1 67} 68 69; 70; VPERMIL2 71; 72 73; Note: _mm_permute2_pd shouldn't be used for constant shuffles as there will always 74; be a quicker (and smaller) alternative. 75define <2 x double> @vpermil2pd_21(<2 x double> %a0, <2 x double> %a1) { 76; CHECK-LABEL: vpermil2pd_21: 77; CHECK: # %bb.0: 78; CHECK-NEXT: vxorps %xmm1, %xmm1, %xmm1 79; CHECK-NEXT: vmovlhps {{.*#+}} xmm0 = xmm1[0],xmm0[0] 80; CHECK-NEXT: ret{{[l|q]}} 81 %1 = call <2 x double> @llvm.x86.xop.vpermil2pd(<2 x double> %a0, <2 x double> %a1, <2 x i64> <i64 10, i64 1>, i8 2) 82 ret <2 x double> %1 83} 84 85define <4 x double> @vpermil2pd256_0062(<4 x double> %a0, <4 x double> %a1) { 86; CHECK-LABEL: vpermil2pd256_0062: 87; CHECK: # %bb.0: 88; CHECK-NEXT: vpermil2pd {{.*#+}} ymm0 = ymm0[0,0],ymm1[2],ymm0[2] 89; CHECK-NEXT: ret{{[l|q]}} 90 %1 = call <4 x double> @llvm.x86.xop.vpermil2pd.256(<4 x double> %a0, <4 x double> %a1, <4 x i64> <i64 0, i64 0, i64 4, i64 0>, i8 0) 91 ret <4 x double> %1 92} 93 94define <4 x double> @vpermil2pd256_zz73(<4 x double> %a0, <4 x double> %a1) { 95; CHECK-LABEL: vpermil2pd256_zz73: 96; CHECK: # %bb.0: 97; CHECK-NEXT: vpermil2pd {{.*#+}} ymm0 = zero,zero,ymm1[3],ymm0[3] 98; CHECK-NEXT: ret{{[l|q]}} 99 %1 = call <4 x double> @llvm.x86.xop.vpermil2pd.256(<4 x double> %a0, <4 x double> %a1, <4 x i64> <i64 0, i64 0, i64 14, i64 10>, i8 3) 100 ret <4 x double> %1 101} 102 103define <4 x float> @vpermil2ps_0561(<4 x float> %a0, <4 x float> %a1) { 104; CHECK-LABEL: vpermil2ps_0561: 105; CHECK: # %bb.0: 106; CHECK-NEXT: vpermil2ps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2],xmm0[1] 107; CHECK-NEXT: ret{{[l|q]}} 108 %1 = call <4 x float> @llvm.x86.xop.vpermil2ps(<4 x float> %a0, <4 x float> %a1, <4 x i32> <i32 0, i32 5, i32 6, i32 1>, i8 0) 109 ret <4 x float> %1 110} 111 112define <8 x float> @vpermil2ps256_098144FE(<8 x float> %a0, <8 x float> %a1) { 113; CHECK-LABEL: vpermil2ps256_098144FE: 114; CHECK: # %bb.0: 115; CHECK-NEXT: vpermil2ps {{.*#+}} ymm0 = ymm0[0],ymm1[1,0],ymm0[1,4,4],ymm1[7,6] 116; CHECK-NEXT: ret{{[l|q]}} 117 %1 = call <8 x float> @llvm.x86.xop.vpermil2ps.256(<8 x float> %a0, <8 x float> %a1, <8 x i32> <i32 0, i32 5, i32 4, i32 1, i32 0, i32 0, i32 7, i32 6>, i8 0) 118 ret <8 x float> %1 119} 120 121define <8 x float> @vpermil2ps256_0zz8BzzA(<8 x float> %a0, <8 x float> %a1) { 122; CHECK-LABEL: vpermil2ps256_0zz8BzzA: 123; CHECK: # %bb.0: 124; CHECK-NEXT: vpermil2ps {{.*#+}} ymm0 = ymm0[0],zero,zero,ymm1[0,7],zero,zero,ymm1[6] 125; CHECK-NEXT: ret{{[l|q]}} 126 %1 = call <8 x float> @llvm.x86.xop.vpermil2ps.256(<8 x float> %a0, <8 x float> %a1, <8 x i32> <i32 0, i32 8, i32 8, i32 4, i32 7, i32 8, i32 8, i32 6>, i8 2) 127 ret <8 x float> %1 128} 129 130declare <2 x double> @llvm.x86.xop.vpermil2pd(<2 x double>, <2 x double>, <2 x i64>, i8) nounwind readnone 131declare <4 x double> @llvm.x86.xop.vpermil2pd.256(<4 x double>, <4 x double>, <4 x i64>, i8) nounwind readnone 132 133declare <4 x float> @llvm.x86.xop.vpermil2ps(<4 x float>, <4 x float>, <4 x i32>, i8) nounwind readnone 134declare <8 x float> @llvm.x86.xop.vpermil2ps.256(<8 x float>, <8 x float>, <8 x i32>, i8) nounwind readnone 135 136declare <16 x i8> @llvm.x86.xop.vpperm(<16 x i8>, <16 x i8>, <16 x i8>) nounwind readnone 137