1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx,+xop | FileCheck %s 3; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2,+xop | FileCheck %s 4 5declare <2 x double> @llvm.x86.xop.vpermil2pd(<2 x double>, <2 x double>, <2 x i64>, i8) nounwind readnone 6declare <4 x double> @llvm.x86.xop.vpermil2pd.256(<4 x double>, <4 x double>, <4 x i64>, i8) nounwind readnone 7 8declare <4 x float> @llvm.x86.xop.vpermil2ps(<4 x float>, <4 x float>, <4 x i32>, i8) nounwind readnone 9declare <8 x float> @llvm.x86.xop.vpermil2ps.256(<8 x float>, <8 x float>, <8 x i32>, i8) nounwind readnone 10 11declare <16 x i8> @llvm.x86.xop.vpperm(<16 x i8>, <16 x i8>, <16 x i8>) nounwind readnone 12 13define <2 x double> @combine_vpermil2pd_identity(<2 x double> %a0, <2 x double> %a1) { 14; CHECK-LABEL: combine_vpermil2pd_identity: 15; CHECK: # BB#0: 16; CHECK-NEXT: vmovaps %xmm1, %xmm0 17; CHECK-NEXT: retq 18 %res0 = call <2 x double> @llvm.x86.xop.vpermil2pd(<2 x double> %a1, <2 x double> %a0, <2 x i64> <i64 2, i64 0>, i8 0) 19 %res1 = call <2 x double> @llvm.x86.xop.vpermil2pd(<2 x double> %res0, <2 x double> undef, <2 x i64> <i64 2, i64 0>, i8 0) 20 ret <2 x double> %res1 21} 22 23define <4 x double> @combine_vpermil2pd256_identity(<4 x double> %a0, <4 x double> %a1) { 24; CHECK-LABEL: combine_vpermil2pd256_identity: 25; CHECK: # BB#0: 26; CHECK-NEXT: vmovaps %ymm1, %ymm0 27; CHECK-NEXT: retq 28 %res0 = call <4 x double> @llvm.x86.xop.vpermil2pd.256(<4 x double> %a1, <4 x double> %a0, <4 x i64> <i64 2, i64 0, i64 2, i64 0>, i8 0) 29 %res1 = call <4 x double> @llvm.x86.xop.vpermil2pd.256(<4 x double> %res0, <4 x double> undef, <4 x i64> <i64 2, i64 0, i64 2, i64 0>, i8 0) 30 ret <4 x double> %res1 31} 32 33define <4 x float> @combine_vpermil2ps_identity(<4 x float> %a0, <4 x float> %a1) { 34; CHECK-LABEL: combine_vpermil2ps_identity: 35; CHECK: # BB#0: 36; CHECK-NEXT: vmovaps %xmm1, %xmm0 37; CHECK-NEXT: retq 38 %res0 = call <4 x float> @llvm.x86.xop.vpermil2ps(<4 x float> %a1, <4 x float> %a0, <4 x i32> <i32 3, i32 2, i32 1, i32 0>, i8 0) 39 %res1 = call <4 x float> @llvm.x86.xop.vpermil2ps(<4 x float> %res0, <4 x float> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>, i8 0) 40 ret <4 x float> %res1 41} 42 43define <8 x float> @combine_vpermil2ps256_identity(<8 x float> %a0, <8 x float> %a1) { 44; CHECK-LABEL: combine_vpermil2ps256_identity: 45; CHECK: # BB#0: 46; CHECK-NEXT: vmovaps %ymm1, %ymm0 47; CHECK-NEXT: retq 48 %res0 = call <8 x float> @llvm.x86.xop.vpermil2ps.256(<8 x float> %a1, <8 x float> %a0, <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 1, i32 0, i32 3, i32 2>, i8 0) 49 %res1 = call <8 x float> @llvm.x86.xop.vpermil2ps.256(<8 x float> %res0, <8 x float> undef, <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 1, i32 0, i32 3, i32 2>, i8 0) 50 ret <8 x float> %res1 51} 52 53define <8 x float> @combine_vpermil2ps256_zero(<8 x float> %a0, <8 x float> %a1) { 54; CHECK-LABEL: combine_vpermil2ps256_zero: 55; CHECK: # BB#0: 56; CHECK-NEXT: vxorps %ymm0, %ymm0, %ymm0 57; CHECK-NEXT: retq 58 %res0 = call <8 x float> @llvm.x86.xop.vpermil2ps.256(<8 x float> %a1, <8 x float> %a0, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 8, i32 9, i32 10, i32 11>, i8 2) 59 ret <8 x float> %res0 60} 61 62define <4 x float> @combine_vpermil2ps_blend_with_zero(<4 x float> %a0, <4 x float> %a1) { 63; CHECK-LABEL: combine_vpermil2ps_blend_with_zero: 64; CHECK: # BB#0: 65; CHECK-NEXT: vxorps %xmm1, %xmm1, %xmm1 66; CHECK-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3] 67; CHECK-NEXT: retq 68 %res0 = call <4 x float> @llvm.x86.xop.vpermil2ps(<4 x float> %a0, <4 x float> %a1, <4 x i32> <i32 8, i32 1, i32 2, i32 3>, i8 2) 69 ret <4 x float> %res0 70} 71 72define <16 x i8> @combine_vpperm_identity(<16 x i8> %a0, <16 x i8> %a1) { 73; CHECK-LABEL: combine_vpperm_identity: 74; CHECK: # BB#0: 75; CHECK-NEXT: vmovaps %xmm1, %xmm0 76; CHECK-NEXT: retq 77 %res0 = call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> %a1, <16 x i8> <i8 31, i8 30, i8 29, i8 28, i8 27, i8 26, i8 25, i8 24, i8 23, i8 22, i8 21, i8 20, i8 19, i8 18, i8 17, i8 16>) 78 %res1 = call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %res0, <16 x i8> undef, <16 x i8> <i8 15, i8 14, i8 13, i8 12, i8 11, i8 10, i8 9, i8 8, i8 7, i8 6, i8 5, i8 4, i8 3, i8 2, i8 1, i8 0>) 79 ret <16 x i8> %res1 80} 81 82define <16 x i8> @combine_vpperm_zero(<16 x i8> %a0, <16 x i8> %a1) { 83; CHECK-LABEL: combine_vpperm_zero: 84; CHECK: # BB#0: 85; CHECK-NEXT: vxorps %xmm0, %xmm0, %xmm0 86; CHECK-NEXT: retq 87 %res0 = call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> %a1, <16 x i8> <i8 128, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0>) 88 %res1 = call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %res0, <16 x i8> undef, <16 x i8> <i8 0, i8 128, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0>) 89 %res2 = call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %res1, <16 x i8> undef, <16 x i8> <i8 0, i8 1, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128>) 90 ret <16 x i8> %res2 91} 92 93define <16 x i8> @combine_vpperm_identity_bitcast(<16 x i8> %a0, <16 x i8> %a1) { 94; CHECK-LABEL: combine_vpperm_identity_bitcast: 95; CHECK: # BB#0: 96; CHECK-NEXT: vpaddq {{.*}}(%rip), %xmm0, %xmm0 97; CHECK-NEXT: retq 98 %mask = bitcast <2 x i64> <i64 1084818905618843912, i64 506097522914230528> to <16 x i8> 99 %res0 = call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> %a1, <16 x i8> %mask) 100 %res1 = call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %res0, <16 x i8> undef, <16 x i8> %mask) 101 %res2 = bitcast <16 x i8> %res1 to <2 x i64> 102 %res3 = add <2 x i64> %res2, <i64 1084818905618843912, i64 506097522914230528> 103 %res4 = bitcast <2 x i64> %res3 to <16 x i8> 104 ret <16 x i8> %res4 105} 106 107define <16 x i8> @combine_vpperm_as_blend_with_zero(<16 x i8> %a0, <16 x i8> %a1) { 108; CHECK-LABEL: combine_vpperm_as_blend_with_zero: 109; CHECK: # BB#0: 110; CHECK-NEXT: vpxor %xmm1, %xmm1, %xmm1 111; CHECK-NEXT: vpblendw {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2,3],xmm1[4,5,6,7] 112; CHECK-NEXT: retq 113 %res0 = call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> %a1, <16 x i8> <i8 0, i8 1, i8 128, i8 129, i8 4, i8 5, i8 6, i8 7, i8 130, i8 131, i8 132, i8 133, i8 134, i8 135, i8 136, i8 137>) 114 ret <16 x i8> %res0 115} 116 117define <16 x i8> @combine_vpperm_as_unary_unpckhwd(<16 x i8> %a0, <16 x i8> %a1) { 118; CHECK-LABEL: combine_vpperm_as_unary_unpckhwd: 119; CHECK: # BB#0: 120; CHECK-NEXT: vpunpckhbw {{.*#+}} xmm0 = xmm0[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15] 121; CHECK-NEXT: retq 122 %res0 = call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> %a0, <16 x i8> <i8 8, i8 undef, i8 9, i8 25, i8 10, i8 26, i8 11, i8 27, i8 12, i8 28, i8 13, i8 29, i8 14, i8 30, i8 15, i8 31>) 123 ret <16 x i8> %res0 124} 125 126define <16 x i8> @combine_vpperm_as_unpckhwd(<16 x i8> %a0, <16 x i8> %a1) { 127; CHECK-LABEL: combine_vpperm_as_unpckhwd: 128; CHECK: # BB#0: 129; CHECK-NEXT: vpperm {{.*#+}} xmm0 = xmm0[8],xmm1[8],xmm0[9],xmm1[9],xmm0[10],xmm1[10],xmm0[11],xmm1[11],xmm0[12],xmm1[12],xmm0[13],xmm1[13],xmm0[14],xmm1[14],xmm0[15],xmm1[15] 130; CHECK-NEXT: retq 131 %res0 = call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> %a1, <16 x i8> <i8 8, i8 24, i8 9, i8 25, i8 10, i8 26, i8 11, i8 27, i8 12, i8 28, i8 13, i8 29, i8 14, i8 30, i8 15, i8 31>) 132 ret <16 x i8> %res0 133} 134