blob: dda93aca9b8eceb1bc3f0bf6286eba6ac02b2700 [file] [log] [blame]
Simon Pilgrim9b7aaaf2016-03-14 00:18:26 +00001; 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 double>, i8) nounwind readnone
6declare <4 x double> @llvm.x86.xop.vpermil2pd.256(<4 x double>, <4 x double>, <4 x double>, i8) nounwind readnone
7
8declare <4 x float> @llvm.x86.xop.vpermil2ps(<4 x float>, <4 x float>, <4 x float>, i8) nounwind readnone
9declare <8 x float> @llvm.x86.xop.vpermil2ps.256(<8 x float>, <8 x float>, <8 x float>, 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 <16 x i8> @combine_vpperm_identity(<16 x i8> %a0, <16 x i8> %a1) {
14; CHECK-LABEL: combine_vpperm_identity:
15; CHECK: # BB#0:
Simon Pilgrimfd4b9b02016-04-16 17:52:07 +000016; CHECK-NEXT: vmovaps %xmm1, %xmm0
Simon Pilgrim9b7aaaf2016-03-14 00:18:26 +000017; CHECK-NEXT: retq
18 %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>)
19 %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>)
20 ret <16 x i8> %res1
21}
22
Simon Pilgrim7eedee92016-04-24 13:45:30 +000023define <16 x i8> @combine_vpperm_zero(<16 x i8> %a0, <16 x i8> %a1) {
24; CHECK-LABEL: combine_vpperm_zero:
25; CHECK: # BB#0:
Simon Pilgrimf379a6c2016-04-24 15:05:04 +000026; CHECK-NEXT: vxorps %xmm0, %xmm0, %xmm0
Simon Pilgrim7eedee92016-04-24 13:45:30 +000027; CHECK-NEXT: retq
28 %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>)
29 %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>)
30 %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>)
31 ret <16 x i8> %res2
32}
33
Simon Pilgrimfd4b9b02016-04-16 17:52:07 +000034define <16 x i8> @combine_vpperm_identity_bitcast(<16 x i8> %a0, <16 x i8> %a1) {
35; CHECK-LABEL: combine_vpperm_identity_bitcast:
36; CHECK: # BB#0:
37; CHECK-NEXT: vpaddq {{.*}}(%rip), %xmm0, %xmm0
38; CHECK-NEXT: retq
39 %mask = bitcast <2 x i64> <i64 1084818905618843912, i64 506097522914230528> to <16 x i8>
40 %res0 = call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> %a1, <16 x i8> %mask)
41 %res1 = call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %res0, <16 x i8> undef, <16 x i8> %mask)
42 %res2 = bitcast <16 x i8> %res1 to <2 x i64>
43 %res3 = add <2 x i64> %res2, <i64 1084818905618843912, i64 506097522914230528>
44 %res4 = bitcast <2 x i64> %res3 to <16 x i8>
45 ret <16 x i8> %res4
46}
47
Simon Pilgrim9448b112016-04-23 11:14:18 +000048define <16 x i8> @combine_vpperm_as_blend_with_zero(<16 x i8> %a0, <16 x i8> %a1) {
49; CHECK-LABEL: combine_vpperm_as_blend_with_zero:
50; CHECK: # BB#0:
51; CHECK-NEXT: vpperm {{.*#+}} xmm0 = xmm0[0,1],zero,zero,xmm0[4,5,6,7],zero,zero,zero,zero,zero,zero,zero,zero
52; CHECK-NEXT: retq
53 %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>)
54 ret <16 x i8> %res0
55}
56
Simon Pilgrim572ca712016-03-24 11:52:43 +000057define <16 x i8> @combine_vpperm_as_unary_unpckhwd(<16 x i8> %a0, <16 x i8> %a1) {
58; CHECK-LABEL: combine_vpperm_as_unary_unpckhwd:
Simon Pilgrim9b7aaaf2016-03-14 00:18:26 +000059; CHECK: # BB#0:
Simon Pilgrimfd4b9b02016-04-16 17:52:07 +000060; CHECK-NEXT: vpunpckhbw {{.*#+}} xmm0 = xmm0[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
Simon Pilgrim9b7aaaf2016-03-14 00:18:26 +000061; CHECK-NEXT: retq
62 %res0 = call <16 x i8> @llvm.x86.xop.vpperm(<16 x i8> %a0, <16 x i8> %a0, <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>)
63 ret <16 x i8> %res0
64}
Simon Pilgrim572ca712016-03-24 11:52:43 +000065
66define <16 x i8> @combine_vpperm_as_unpckhwd(<16 x i8> %a0, <16 x i8> %a1) {
67; CHECK-LABEL: combine_vpperm_as_unpckhwd:
68; CHECK: # BB#0:
Simon Pilgrim1cc57122016-04-09 14:51:26 +000069; 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]
Simon Pilgrim572ca712016-03-24 11:52:43 +000070; CHECK-NEXT: retq
71 %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>)
72 ret <16 x i8> %res0
73}