1; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=skx | FileCheck %s
2
3; CHECK-LABEL: test256_1
4; CHECK: vpcmpeqb {{.*%k[0-7]}}
5; CHECK: vmovdqu8 {{.*}}%k1
6; CHECK: ret
7define <32 x i8> @test256_1(<32 x i8> %x, <32 x i8> %y) nounwind {
8  %mask = icmp eq <32 x i8> %x, %y
9  %max = select <32 x i1> %mask, <32 x i8> %x, <32 x i8> %y
10  ret <32 x i8> %max
11}
12
13; CHECK-LABEL: test256_2
14; CHECK: vpcmpgtb {{.*%k[0-7]}}
15; CHECK: vmovdqu8 {{.*}}%k1
16; CHECK: ret
17define <32 x i8> @test256_2(<32 x i8> %x, <32 x i8> %y, <32 x i8> %x1) nounwind {
18  %mask = icmp sgt <32 x i8> %x, %y
19  %max = select <32 x i1> %mask, <32 x i8> %x, <32 x i8> %x1
20  ret <32 x i8> %max
21}
22
23; CHECK-LABEL: @test256_3
24; CHECK: vpcmplew {{.*%k[0-7]}}
25; CHECK: vmovdqu16
26; CHECK: ret
27define <16 x i16> @test256_3(<16 x i16> %x, <16 x i16> %y, <16 x i16> %x1) nounwind {
28  %mask = icmp sge <16 x i16> %x, %y
29  %max = select <16 x i1> %mask, <16 x i16> %x1, <16 x i16> %y
30  ret <16 x i16> %max
31}
32
33; CHECK-LABEL: test256_4
34; CHECK: vpcmpnleub {{.*%k[0-7]}}
35; CHECK: vmovdqu8 {{.*}}%k1
36; CHECK: ret
37define <32 x i8> @test256_4(<32 x i8> %x, <32 x i8> %y, <32 x i8> %x1) nounwind {
38  %mask = icmp ugt <32 x i8> %x, %y
39  %max = select <32 x i1> %mask, <32 x i8> %x, <32 x i8> %x1
40  ret <32 x i8> %max
41}
42
43; CHECK-LABEL: test256_5
44; CHECK: vpcmpeqw  (%rdi){{.*%k[0-7]}}
45; CHECK: vmovdqu16
46; CHECK: ret
47define <16 x i16> @test256_5(<16 x i16> %x, <16 x i16> %x1, <16 x i16>* %yp) nounwind {
48  %y = load <16 x i16>* %yp, align 4
49  %mask = icmp eq <16 x i16> %x, %y
50  %max = select <16 x i1> %mask, <16 x i16> %x, <16 x i16> %x1
51  ret <16 x i16> %max
52}
53
54; CHECK-LABEL: @test256_6
55; CHECK: vpcmpgtw (%rdi){{.*%k[0-7]}}
56; CHECK: vmovdqu16
57; CHECK: ret
58define <16 x i16> @test256_6(<16 x i16> %x, <16 x i16> %x1, <16 x i16>* %y.ptr) nounwind {
59  %y = load <16 x i16>* %y.ptr, align 4
60  %mask = icmp sgt <16 x i16> %x, %y
61  %max = select <16 x i1> %mask, <16 x i16> %x, <16 x i16> %x1
62  ret <16 x i16> %max
63}
64
65; CHECK-LABEL: @test256_7
66; CHECK: vpcmplew (%rdi){{.*%k[0-7]}}
67; CHECK: vmovdqu16
68; CHECK: ret
69define <16 x i16> @test256_7(<16 x i16> %x, <16 x i16> %x1, <16 x i16>* %y.ptr) nounwind {
70  %y = load <16 x i16>* %y.ptr, align 4
71  %mask = icmp sle <16 x i16> %x, %y
72  %max = select <16 x i1> %mask, <16 x i16> %x, <16 x i16> %x1
73  ret <16 x i16> %max
74}
75
76; CHECK-LABEL: @test256_8
77; CHECK: vpcmpleuw (%rdi){{.*%k[0-7]}}
78; CHECK: vmovdqu16
79; CHECK: ret
80define <16 x i16> @test256_8(<16 x i16> %x, <16 x i16> %x1, <16 x i16>* %y.ptr) nounwind {
81  %y = load <16 x i16>* %y.ptr, align 4
82  %mask = icmp ule <16 x i16> %x, %y
83  %max = select <16 x i1> %mask, <16 x i16> %x, <16 x i16> %x1
84  ret <16 x i16> %max
85}
86
87; CHECK-LABEL: @test256_9
88; CHECK: vpcmpeqw %ymm{{.*{%k[1-7]}}}
89; CHECK: vmovdqu16
90; CHECK: ret
91define <16 x i16> @test256_9(<16 x i16> %x, <16 x i16> %y, <16 x i16> %x1, <16 x i16> %y1) nounwind {
92  %mask1 = icmp eq <16 x i16> %x1, %y1
93  %mask0 = icmp eq <16 x i16> %x, %y
94  %mask = select <16 x i1> %mask0, <16 x i1> %mask1, <16 x i1> zeroinitializer
95  %max = select <16 x i1> %mask, <16 x i16> %x, <16 x i16> %y
96  ret <16 x i16> %max
97}
98
99; CHECK-LABEL: @test256_10
100; CHECK: vpcmpleb %ymm{{.*{%k[1-7]}}}
101; CHECK: vmovdqu8
102; CHECK: ret
103define <32 x i8> @test256_10(<32 x i8> %x, <32 x i8> %y, <32 x i8> %x1, <32 x i8> %y1) nounwind {
104  %mask1 = icmp sge <32 x i8> %x1, %y1
105  %mask0 = icmp sle <32 x i8> %x, %y
106  %mask = select <32 x i1> %mask0, <32 x i1> %mask1, <32 x i1> zeroinitializer
107  %max = select <32 x i1> %mask, <32 x i8> %x, <32 x i8> %x1
108  ret <32 x i8> %max
109}
110
111; CHECK-LABEL: @test256_11
112; CHECK: vpcmpgtb (%rdi){{.*{%k[1-7]}}}
113; CHECK: vmovdqu8
114; CHECK: ret
115define <32 x i8> @test256_11(<32 x i8> %x, <32 x i8>* %y.ptr, <32 x i8> %x1, <32 x i8> %y1) nounwind {
116  %mask1 = icmp sgt <32 x i8> %x1, %y1
117  %y = load <32 x i8>* %y.ptr, align 4
118  %mask0 = icmp sgt <32 x i8> %x, %y
119  %mask = select <32 x i1> %mask0, <32 x i1> %mask1, <32 x i1> zeroinitializer
120  %max = select <32 x i1> %mask, <32 x i8> %x, <32 x i8> %x1
121  ret <32 x i8> %max
122}
123
124; CHECK-LABEL: @test256_12
125; CHECK: vpcmpleuw (%rdi){{.*{%k[1-7]}}}
126; CHECK: vmovdqu16
127; CHECK: ret
128define <16 x i16> @test256_12(<16 x i16> %x, <16 x i16>* %y.ptr, <16 x i16> %x1, <16 x i16> %y1) nounwind {
129  %mask1 = icmp sge <16 x i16> %x1, %y1
130  %y = load <16 x i16>* %y.ptr, align 4
131  %mask0 = icmp ule <16 x i16> %x, %y
132  %mask = select <16 x i1> %mask0, <16 x i1> %mask1, <16 x i1> zeroinitializer
133  %max = select <16 x i1> %mask, <16 x i16> %x, <16 x i16> %x1
134  ret <16 x i16> %max
135}
136
137; CHECK-LABEL: test128_1
138; CHECK: vpcmpeqb {{.*%k[0-7]}}
139; CHECK: vmovdqu8 {{.*}}%k1
140; CHECK: ret
141define <16 x i8> @test128_1(<16 x i8> %x, <16 x i8> %y) nounwind {
142  %mask = icmp eq <16 x i8> %x, %y
143  %max = select <16 x i1> %mask, <16 x i8> %x, <16 x i8> %y
144  ret <16 x i8> %max
145}
146
147; CHECK-LABEL: test128_2
148; CHECK: vpcmpgtb {{.*%k[0-7]}}
149; CHECK: vmovdqu8 {{.*}}%k1
150; CHECK: ret
151define <16 x i8> @test128_2(<16 x i8> %x, <16 x i8> %y, <16 x i8> %x1) nounwind {
152  %mask = icmp sgt <16 x i8> %x, %y
153  %max = select <16 x i1> %mask, <16 x i8> %x, <16 x i8> %x1
154  ret <16 x i8> %max
155}
156
157; CHECK-LABEL: @test128_3
158; CHECK: vpcmplew {{.*%k[0-7]}}
159; CHECK: vmovdqu16
160; CHECK: ret
161define <8 x i16> @test128_3(<8 x i16> %x, <8 x i16> %y, <8 x i16> %x1) nounwind {
162  %mask = icmp sge <8 x i16> %x, %y
163  %max = select <8 x i1> %mask, <8 x i16> %x1, <8 x i16> %y
164  ret <8 x i16> %max
165}
166
167; CHECK-LABEL: test128_4
168; CHECK: vpcmpnleub {{.*%k[0-7]}}
169; CHECK: vmovdqu8 {{.*}}%k1
170; CHECK: ret
171define <16 x i8> @test128_4(<16 x i8> %x, <16 x i8> %y, <16 x i8> %x1) nounwind {
172  %mask = icmp ugt <16 x i8> %x, %y
173  %max = select <16 x i1> %mask, <16 x i8> %x, <16 x i8> %x1
174  ret <16 x i8> %max
175}
176
177; CHECK-LABEL: test128_5
178; CHECK: vpcmpeqw  (%rdi){{.*%k[0-7]}}
179; CHECK: vmovdqu16
180; CHECK: ret
181define <8 x i16> @test128_5(<8 x i16> %x, <8 x i16> %x1, <8 x i16>* %yp) nounwind {
182  %y = load <8 x i16>* %yp, align 4
183  %mask = icmp eq <8 x i16> %x, %y
184  %max = select <8 x i1> %mask, <8 x i16> %x, <8 x i16> %x1
185  ret <8 x i16> %max
186}
187
188; CHECK-LABEL: @test128_6
189; CHECK: vpcmpgtw (%rdi){{.*%k[0-7]}}
190; CHECK: vmovdqu16
191; CHECK: ret
192define <8 x i16> @test128_6(<8 x i16> %x, <8 x i16> %x1, <8 x i16>* %y.ptr) nounwind {
193  %y = load <8 x i16>* %y.ptr, align 4
194  %mask = icmp sgt <8 x i16> %x, %y
195  %max = select <8 x i1> %mask, <8 x i16> %x, <8 x i16> %x1
196  ret <8 x i16> %max
197}
198
199; CHECK-LABEL: @test128_7
200; CHECK: vpcmplew (%rdi){{.*%k[0-7]}}
201; CHECK: vmovdqu16
202; CHECK: ret
203define <8 x i16> @test128_7(<8 x i16> %x, <8 x i16> %x1, <8 x i16>* %y.ptr) nounwind {
204  %y = load <8 x i16>* %y.ptr, align 4
205  %mask = icmp sle <8 x i16> %x, %y
206  %max = select <8 x i1> %mask, <8 x i16> %x, <8 x i16> %x1
207  ret <8 x i16> %max
208}
209
210; CHECK-LABEL: @test128_8
211; CHECK: vpcmpleuw (%rdi){{.*%k[0-7]}}
212; CHECK: vmovdqu16
213; CHECK: ret
214define <8 x i16> @test128_8(<8 x i16> %x, <8 x i16> %x1, <8 x i16>* %y.ptr) nounwind {
215  %y = load <8 x i16>* %y.ptr, align 4
216  %mask = icmp ule <8 x i16> %x, %y
217  %max = select <8 x i1> %mask, <8 x i16> %x, <8 x i16> %x1
218  ret <8 x i16> %max
219}
220
221; CHECK-LABEL: @test128_9
222; CHECK: vpcmpeqw %xmm{{.*{%k[1-7]}}}
223; CHECK: vmovdqu16
224; CHECK: ret
225define <8 x i16> @test128_9(<8 x i16> %x, <8 x i16> %y, <8 x i16> %x1, <8 x i16> %y1) nounwind {
226  %mask1 = icmp eq <8 x i16> %x1, %y1
227  %mask0 = icmp eq <8 x i16> %x, %y
228  %mask = select <8 x i1> %mask0, <8 x i1> %mask1, <8 x i1> zeroinitializer
229  %max = select <8 x i1> %mask, <8 x i16> %x, <8 x i16> %y
230  ret <8 x i16> %max
231}
232
233; CHECK-LABEL: @test128_10
234; CHECK: vpcmpleb %xmm{{.*{%k[1-7]}}}
235; CHECK: vmovdqu8
236; CHECK: ret
237define <16 x i8> @test128_10(<16 x i8> %x, <16 x i8> %y, <16 x i8> %x1, <16 x i8> %y1) nounwind {
238  %mask1 = icmp sge <16 x i8> %x1, %y1
239  %mask0 = icmp sle <16 x i8> %x, %y
240  %mask = select <16 x i1> %mask0, <16 x i1> %mask1, <16 x i1> zeroinitializer
241  %max = select <16 x i1> %mask, <16 x i8> %x, <16 x i8> %x1
242  ret <16 x i8> %max
243}
244
245; CHECK-LABEL: @test128_11
246; CHECK: vpcmpgtb (%rdi){{.*{%k[1-7]}}}
247; CHECK: vmovdqu8
248; CHECK: ret
249define <16 x i8> @test128_11(<16 x i8> %x, <16 x i8>* %y.ptr, <16 x i8> %x1, <16 x i8> %y1) nounwind {
250  %mask1 = icmp sgt <16 x i8> %x1, %y1
251  %y = load <16 x i8>* %y.ptr, align 4
252  %mask0 = icmp sgt <16 x i8> %x, %y
253  %mask = select <16 x i1> %mask0, <16 x i1> %mask1, <16 x i1> zeroinitializer
254  %max = select <16 x i1> %mask, <16 x i8> %x, <16 x i8> %x1
255  ret <16 x i8> %max
256}
257
258; CHECK-LABEL: @test128_12
259; CHECK: vpcmpleuw (%rdi){{.*{%k[1-7]}}}
260; CHECK: vmovdqu16
261; CHECK: ret
262define <8 x i16> @test128_12(<8 x i16> %x, <8 x i16>* %y.ptr, <8 x i16> %x1, <8 x i16> %y1) nounwind {
263  %mask1 = icmp sge <8 x i16> %x1, %y1
264  %y = load <8 x i16>* %y.ptr, align 4
265  %mask0 = icmp ule <8 x i16> %x, %y
266  %mask = select <8 x i1> %mask0, <8 x i1> %mask1, <8 x i1> zeroinitializer
267  %max = select <8 x i1> %mask, <8 x i16> %x, <8 x i16> %x1
268  ret <8 x i16> %max
269}
270