Add a triple to switch.ll test.
[oota-llvm.git] / test / CodeGen / X86 / avx512vl-vec-cmp.ll
1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=skx | FileCheck %s
2
3 ; CHECK-LABEL: test256_1
4 ; CHECK: vpcmpeqq {{.*%k[0-7]}}
5 ; CHECK: vmovdqa64 {{.*}}%k1
6 ; CHECK: ret
7 define <4 x i64> @test256_1(<4 x i64> %x, <4 x i64> %y) nounwind {
8   %mask = icmp eq <4 x i64> %x, %y
9   %max = select <4 x i1> %mask, <4 x i64> %x, <4 x i64> %y
10   ret <4 x i64> %max
11 }
12
13 ; CHECK-LABEL: test256_2
14 ; CHECK: vpcmpgtq {{.*%k[0-7]}}
15 ; CHECK: vmovdqa64 {{.*}}%k1
16 ; CHECK: ret
17 define <4 x i64> @test256_2(<4 x i64> %x, <4 x i64> %y, <4 x i64> %x1) nounwind {
18   %mask = icmp sgt <4 x i64> %x, %y
19   %max = select <4 x i1> %mask, <4 x i64> %x1, <4 x i64> %y
20   ret <4 x i64> %max
21 }
22
23 ; CHECK-LABEL: @test256_3
24 ; CHECK: vpcmpled {{.*%k[0-7]}}
25 ; CHECK: vmovdqa32
26 ; CHECK: ret
27 define <8 x i32> @test256_3(<8 x i32> %x, <8 x i32> %y, <8 x i32> %x1) nounwind {
28   %mask = icmp sge <8 x i32> %x, %y
29   %max = select <8 x i1> %mask, <8 x i32> %x1, <8 x i32> %y
30   ret <8 x i32> %max
31 }
32
33 ; CHECK-LABEL: test256_4
34 ; CHECK: vpcmpnleuq {{.*%k[0-7]}}
35 ; CHECK: vmovdqa64 {{.*}}%k1
36 ; CHECK: ret
37 define <4 x i64> @test256_4(<4 x i64> %x, <4 x i64> %y, <4 x i64> %x1) nounwind {
38   %mask = icmp ugt <4 x i64> %x, %y
39   %max = select <4 x i1> %mask, <4 x i64> %x1, <4 x i64> %y
40   ret <4 x i64> %max
41 }
42
43 ; CHECK-LABEL: test256_5
44 ; CHECK: vpcmpeqd  (%rdi){{.*%k[0-7]}}
45 ; CHECK: vmovdqa32
46 ; CHECK: ret
47 define <8 x i32> @test256_5(<8 x i32> %x, <8 x i32> %x1, <8 x i32>* %yp) nounwind {
48   %y = load <8 x i32>, <8 x i32>* %yp, align 4
49   %mask = icmp eq <8 x i32> %x, %y
50   %max = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> %x1
51   ret <8 x i32> %max
52 }
53
54 ; CHECK-LABEL: @test256_6
55 ; CHECK: vpcmpgtd (%rdi){{.*%k[0-7]}}
56 ; CHECK: vmovdqa32
57 ; CHECK: ret
58 define <8 x i32> @test256_6(<8 x i32> %x, <8 x i32> %x1, <8 x i32>* %y.ptr) nounwind {
59   %y = load <8 x i32>, <8 x i32>* %y.ptr, align 4
60   %mask = icmp sgt <8 x i32> %x, %y
61   %max = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> %x1
62   ret <8 x i32> %max
63 }
64
65 ; CHECK-LABEL: @test256_7
66 ; CHECK: vpcmpled (%rdi){{.*%k[0-7]}}
67 ; CHECK: vmovdqa32
68 ; CHECK: ret
69 define <8 x i32> @test256_7(<8 x i32> %x, <8 x i32> %x1, <8 x i32>* %y.ptr) nounwind {
70   %y = load <8 x i32>, <8 x i32>* %y.ptr, align 4
71   %mask = icmp sle <8 x i32> %x, %y
72   %max = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> %x1
73   ret <8 x i32> %max
74 }
75
76 ; CHECK-LABEL: @test256_8
77 ; CHECK: vpcmpleud (%rdi){{.*%k[0-7]}}
78 ; CHECK: vmovdqa32
79 ; CHECK: ret
80 define <8 x i32> @test256_8(<8 x i32> %x, <8 x i32> %x1, <8 x i32>* %y.ptr) nounwind {
81   %y = load <8 x i32>, <8 x i32>* %y.ptr, align 4
82   %mask = icmp ule <8 x i32> %x, %y
83   %max = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> %x1
84   ret <8 x i32> %max
85 }
86
87 ; CHECK-LABEL: @test256_9
88 ; CHECK: vpcmpeqd %ymm{{.*{%k[1-7]}}}
89 ; CHECK: vmovdqa32
90 ; CHECK: ret
91 define <8 x i32> @test256_9(<8 x i32> %x, <8 x i32> %y, <8 x i32> %x1, <8 x i32> %y1) nounwind {
92   %mask1 = icmp eq <8 x i32> %x1, %y1
93   %mask0 = icmp eq <8 x i32> %x, %y
94   %mask = select <8 x i1> %mask0, <8 x i1> %mask1, <8 x i1> zeroinitializer
95   %max = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> %y
96   ret <8 x i32> %max
97 }
98
99 ; CHECK-LABEL: @test256_10
100 ; CHECK: vpcmpleq %ymm{{.*{%k[1-7]}}}
101 ; CHECK: vmovdqa64
102 ; CHECK: ret
103 define <4 x i64> @test256_10(<4 x i64> %x, <4 x i64> %y, <4 x i64> %x1, <4 x i64> %y1) nounwind {
104   %mask1 = icmp sge <4 x i64> %x1, %y1
105   %mask0 = icmp sle <4 x i64> %x, %y
106   %mask = select <4 x i1> %mask0, <4 x i1> %mask1, <4 x i1> zeroinitializer
107   %max = select <4 x i1> %mask, <4 x i64> %x, <4 x i64> %x1
108   ret <4 x i64> %max
109 }
110
111 ; CHECK-LABEL: @test256_11
112 ; CHECK: vpcmpgtq (%rdi){{.*{%k[1-7]}}}
113 ; CHECK: vmovdqa64
114 ; CHECK: ret
115 define <4 x i64> @test256_11(<4 x i64> %x, <4 x i64>* %y.ptr, <4 x i64> %x1, <4 x i64> %y1) nounwind {
116   %mask1 = icmp sgt <4 x i64> %x1, %y1
117   %y = load <4 x i64>, <4 x i64>* %y.ptr, align 4
118   %mask0 = icmp sgt <4 x i64> %x, %y
119   %mask = select <4 x i1> %mask0, <4 x i1> %mask1, <4 x i1> zeroinitializer
120   %max = select <4 x i1> %mask, <4 x i64> %x, <4 x i64> %x1
121   ret <4 x i64> %max
122 }
123
124 ; CHECK-LABEL: @test256_12
125 ; CHECK: vpcmpleud (%rdi){{.*{%k[1-7]}}}
126 ; CHECK: vmovdqa32
127 ; CHECK: ret
128 define <8 x i32> @test256_12(<8 x i32> %x, <8 x i32>* %y.ptr, <8 x i32> %x1, <8 x i32> %y1) nounwind {
129   %mask1 = icmp sge <8 x i32> %x1, %y1
130   %y = load <8 x i32>, <8 x i32>* %y.ptr, align 4
131   %mask0 = icmp ule <8 x i32> %x, %y
132   %mask = select <8 x i1> %mask0, <8 x i1> %mask1, <8 x i1> zeroinitializer
133   %max = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> %x1
134   ret <8 x i32> %max
135 }
136
137 ; CHECK-LABEL: test256_13
138 ; CHECK: vpcmpeqq  (%rdi){1to4}, %ymm
139 ; CHECK: vmovdqa64
140 ; CHECK: ret
141 define <4 x i64> @test256_13(<4 x i64> %x, <4 x i64> %x1, i64* %yb.ptr) nounwind {
142   %yb = load i64, i64* %yb.ptr, align 4
143   %y.0 = insertelement <4 x i64> undef, i64 %yb, i32 0
144   %y = shufflevector <4 x i64> %y.0, <4 x i64> undef, <4 x i32> zeroinitializer
145   %mask = icmp eq <4 x i64> %x, %y
146   %max = select <4 x i1> %mask, <4 x i64> %x, <4 x i64> %x1
147   ret <4 x i64> %max
148 }
149
150 ; CHECK-LABEL: test256_14
151 ; CHECK: vpcmpled  (%rdi){1to8}, %ymm
152 ; CHECK: vmovdqa32
153 ; CHECK: ret
154 define <8 x i32> @test256_14(<8 x i32> %x, i32* %yb.ptr, <8 x i32> %x1) nounwind {
155   %yb = load i32, i32* %yb.ptr, align 4
156   %y.0 = insertelement <8 x i32> undef, i32 %yb, i32 0
157   %y = shufflevector <8 x i32> %y.0, <8 x i32> undef, <8 x i32> zeroinitializer
158   %mask = icmp sle <8 x i32> %x, %y
159   %max = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> %x1
160   ret <8 x i32> %max
161 }
162
163 ; CHECK-LABEL: test256_15
164 ; CHECK: vpcmpgtd  (%rdi){1to8}, %ymm{{.*{%k[1-7]}}}
165 ; CHECK: vmovdqa32
166 ; CHECK: ret
167 define <8 x i32> @test256_15(<8 x i32> %x, i32* %yb.ptr, <8 x i32> %x1, <8 x i32> %y1) nounwind {
168   %mask1 = icmp sge <8 x i32> %x1, %y1
169   %yb = load i32, i32* %yb.ptr, align 4
170   %y.0 = insertelement <8 x i32> undef, i32 %yb, i32 0
171   %y = shufflevector <8 x i32> %y.0, <8 x i32> undef, <8 x i32> zeroinitializer
172   %mask0 = icmp sgt <8 x i32> %x, %y
173   %mask = select <8 x i1> %mask0, <8 x i1> %mask1, <8 x i1> zeroinitializer
174   %max = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> %x1
175   ret <8 x i32> %max
176 }
177
178 ; CHECK-LABEL: test256_16
179 ; CHECK: vpcmpgtq  (%rdi){1to4}, %ymm{{.*{%k[1-7]}}}
180 ; CHECK: vmovdqa64
181 ; CHECK: ret
182 define <4 x i64> @test256_16(<4 x i64> %x, i64* %yb.ptr, <4 x i64> %x1, <4 x i64> %y1) nounwind {
183   %mask1 = icmp sge <4 x i64> %x1, %y1
184   %yb = load i64, i64* %yb.ptr, align 4
185   %y.0 = insertelement <4 x i64> undef, i64 %yb, i32 0
186   %y = shufflevector <4 x i64> %y.0, <4 x i64> undef, <4 x i32> zeroinitializer
187   %mask0 = icmp sgt <4 x i64> %x, %y
188   %mask = select <4 x i1> %mask0, <4 x i1> %mask1, <4 x i1> zeroinitializer
189   %max = select <4 x i1> %mask, <4 x i64> %x, <4 x i64> %x1
190   ret <4 x i64> %max
191 }
192
193 ; CHECK-LABEL: test128_1
194 ; CHECK: vpcmpeqq {{.*%k[0-7]}}
195 ; CHECK: vmovdqa64 {{.*}}%k1
196 ; CHECK: ret
197 define <2 x i64> @test128_1(<2 x i64> %x, <2 x i64> %y) nounwind {
198   %mask = icmp eq <2 x i64> %x, %y
199   %max = select <2 x i1> %mask, <2 x i64> %x, <2 x i64> %y
200   ret <2 x i64> %max
201 }
202
203 ; CHECK-LABEL: test128_2
204 ; CHECK: vpcmpgtq {{.*%k[0-7]}}
205 ; CHECK: vmovdqa64 {{.*}}%k1
206 ; CHECK: ret
207 define <2 x i64> @test128_2(<2 x i64> %x, <2 x i64> %y, <2 x i64> %x1) nounwind {
208   %mask = icmp sgt <2 x i64> %x, %y
209   %max = select <2 x i1> %mask, <2 x i64> %x1, <2 x i64> %y
210   ret <2 x i64> %max
211 }
212
213 ; CHECK-LABEL: @test128_3
214 ; CHECK: vpcmpled {{.*%k[0-7]}}
215 ; CHECK: vmovdqa32
216 ; CHECK: ret
217 define <4 x i32> @test128_3(<4 x i32> %x, <4 x i32> %y, <4 x i32> %x1) nounwind {
218   %mask = icmp sge <4 x i32> %x, %y
219   %max = select <4 x i1> %mask, <4 x i32> %x1, <4 x i32> %y
220   ret <4 x i32> %max
221 }
222
223 ; CHECK-LABEL: test128_4
224 ; CHECK: vpcmpnleuq {{.*%k[0-7]}}
225 ; CHECK: vmovdqa64 {{.*}}%k1
226 ; CHECK: ret
227 define <2 x i64> @test128_4(<2 x i64> %x, <2 x i64> %y, <2 x i64> %x1) nounwind {
228   %mask = icmp ugt <2 x i64> %x, %y
229   %max = select <2 x i1> %mask, <2 x i64> %x1, <2 x i64> %y
230   ret <2 x i64> %max
231 }
232
233 ; CHECK-LABEL: test128_5
234 ; CHECK: vpcmpeqd  (%rdi){{.*%k[0-7]}}
235 ; CHECK: vmovdqa32
236 ; CHECK: ret
237 define <4 x i32> @test128_5(<4 x i32> %x, <4 x i32> %x1, <4 x i32>* %yp) nounwind {
238   %y = load <4 x i32>, <4 x i32>* %yp, align 4
239   %mask = icmp eq <4 x i32> %x, %y
240   %max = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> %x1
241   ret <4 x i32> %max
242 }
243
244 ; CHECK-LABEL: @test128_6
245 ; CHECK: vpcmpgtd (%rdi){{.*%k[0-7]}}
246 ; CHECK: vmovdqa32
247 ; CHECK: ret
248 define <4 x i32> @test128_6(<4 x i32> %x, <4 x i32> %x1, <4 x i32>* %y.ptr) nounwind {
249   %y = load <4 x i32>, <4 x i32>* %y.ptr, align 4
250   %mask = icmp sgt <4 x i32> %x, %y
251   %max = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> %x1
252   ret <4 x i32> %max
253 }
254
255 ; CHECK-LABEL: @test128_7
256 ; CHECK: vpcmpled (%rdi){{.*%k[0-7]}}
257 ; CHECK: vmovdqa32
258 ; CHECK: ret
259 define <4 x i32> @test128_7(<4 x i32> %x, <4 x i32> %x1, <4 x i32>* %y.ptr) nounwind {
260   %y = load <4 x i32>, <4 x i32>* %y.ptr, align 4
261   %mask = icmp sle <4 x i32> %x, %y
262   %max = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> %x1
263   ret <4 x i32> %max
264 }
265
266 ; CHECK-LABEL: @test128_8
267 ; CHECK: vpcmpleud (%rdi){{.*%k[0-7]}}
268 ; CHECK: vmovdqa32
269 ; CHECK: ret
270 define <4 x i32> @test128_8(<4 x i32> %x, <4 x i32> %x1, <4 x i32>* %y.ptr) nounwind {
271   %y = load <4 x i32>, <4 x i32>* %y.ptr, align 4
272   %mask = icmp ule <4 x i32> %x, %y
273   %max = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> %x1
274   ret <4 x i32> %max
275 }
276
277 ; CHECK-LABEL: @test128_9
278 ; CHECK: vpcmpeqd %xmm{{.*{%k[1-7]}}}
279 ; CHECK: vmovdqa32
280 ; CHECK: ret
281 define <4 x i32> @test128_9(<4 x i32> %x, <4 x i32> %y, <4 x i32> %x1, <4 x i32> %y1) nounwind {
282   %mask1 = icmp eq <4 x i32> %x1, %y1
283   %mask0 = icmp eq <4 x i32> %x, %y
284   %mask = select <4 x i1> %mask0, <4 x i1> %mask1, <4 x i1> zeroinitializer
285   %max = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> %y
286   ret <4 x i32> %max
287 }
288
289 ; CHECK-LABEL: @test128_10
290 ; CHECK: vpcmpleq %xmm{{.*{%k[1-7]}}}
291 ; CHECK: vmovdqa64
292 ; CHECK: ret
293 define <2 x i64> @test128_10(<2 x i64> %x, <2 x i64> %y, <2 x i64> %x1, <2 x i64> %y1) nounwind {
294   %mask1 = icmp sge <2 x i64> %x1, %y1
295   %mask0 = icmp sle <2 x i64> %x, %y
296   %mask = select <2 x i1> %mask0, <2 x i1> %mask1, <2 x i1> zeroinitializer
297   %max = select <2 x i1> %mask, <2 x i64> %x, <2 x i64> %x1
298   ret <2 x i64> %max
299 }
300
301 ; CHECK-LABEL: @test128_11
302 ; CHECK: vpcmpgtq (%rdi){{.*{%k[1-7]}}}
303 ; CHECK: vmovdqa64
304 ; CHECK: ret
305 define <2 x i64> @test128_11(<2 x i64> %x, <2 x i64>* %y.ptr, <2 x i64> %x1, <2 x i64> %y1) nounwind {
306   %mask1 = icmp sgt <2 x i64> %x1, %y1
307   %y = load <2 x i64>, <2 x i64>* %y.ptr, align 4
308   %mask0 = icmp sgt <2 x i64> %x, %y
309   %mask = select <2 x i1> %mask0, <2 x i1> %mask1, <2 x i1> zeroinitializer
310   %max = select <2 x i1> %mask, <2 x i64> %x, <2 x i64> %x1
311   ret <2 x i64> %max
312 }
313
314 ; CHECK-LABEL: @test128_12
315 ; CHECK: vpcmpleud (%rdi){{.*{%k[1-7]}}}
316 ; CHECK: vmovdqa32
317 ; CHECK: ret
318 define <4 x i32> @test128_12(<4 x i32> %x, <4 x i32>* %y.ptr, <4 x i32> %x1, <4 x i32> %y1) nounwind {
319   %mask1 = icmp sge <4 x i32> %x1, %y1
320   %y = load <4 x i32>, <4 x i32>* %y.ptr, align 4
321   %mask0 = icmp ule <4 x i32> %x, %y
322   %mask = select <4 x i1> %mask0, <4 x i1> %mask1, <4 x i1> zeroinitializer
323   %max = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> %x1
324   ret <4 x i32> %max
325 }
326
327 ; CHECK-LABEL: test128_13
328 ; CHECK: vpcmpeqq  (%rdi){1to2}, %xmm
329 ; CHECK: vmovdqa64
330 ; CHECK: ret
331 define <2 x i64> @test128_13(<2 x i64> %x, <2 x i64> %x1, i64* %yb.ptr) nounwind {
332   %yb = load i64, i64* %yb.ptr, align 4
333   %y.0 = insertelement <2 x i64> undef, i64 %yb, i32 0
334   %y = insertelement <2 x i64> %y.0, i64 %yb, i32 1
335   %mask = icmp eq <2 x i64> %x, %y
336   %max = select <2 x i1> %mask, <2 x i64> %x, <2 x i64> %x1
337   ret <2 x i64> %max
338 }
339
340 ; CHECK-LABEL: test128_14
341 ; CHECK: vpcmpled  (%rdi){1to4}, %xmm
342 ; CHECK: vmovdqa32
343 ; CHECK: ret
344 define <4 x i32> @test128_14(<4 x i32> %x, i32* %yb.ptr, <4 x i32> %x1) nounwind {
345   %yb = load i32, i32* %yb.ptr, align 4
346   %y.0 = insertelement <4 x i32> undef, i32 %yb, i32 0
347   %y = shufflevector <4 x i32> %y.0, <4 x i32> undef, <4 x i32> zeroinitializer
348   %mask = icmp sle <4 x i32> %x, %y
349   %max = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> %x1
350   ret <4 x i32> %max
351 }
352
353 ; CHECK-LABEL: test128_15
354 ; CHECK: vpcmpgtd  (%rdi){1to4}, %xmm{{.*{%k[1-7]}}}
355 ; CHECK: vmovdqa32
356 ; CHECK: ret
357 define <4 x i32> @test128_15(<4 x i32> %x, i32* %yb.ptr, <4 x i32> %x1, <4 x i32> %y1) nounwind {
358   %mask1 = icmp sge <4 x i32> %x1, %y1
359   %yb = load i32, i32* %yb.ptr, align 4
360   %y.0 = insertelement <4 x i32> undef, i32 %yb, i32 0
361   %y = shufflevector <4 x i32> %y.0, <4 x i32> undef, <4 x i32> zeroinitializer
362   %mask0 = icmp sgt <4 x i32> %x, %y
363   %mask = select <4 x i1> %mask0, <4 x i1> %mask1, <4 x i1> zeroinitializer
364   %max = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> %x1
365   ret <4 x i32> %max
366 }
367
368 ; CHECK-LABEL: test128_16
369 ; CHECK: vpcmpgtq  (%rdi){1to2}, %xmm{{.*{%k[1-7]}}}
370 ; CHECK: vmovdqa64
371 ; CHECK: ret
372 define <2 x i64> @test128_16(<2 x i64> %x, i64* %yb.ptr, <2 x i64> %x1, <2 x i64> %y1) nounwind {
373   %mask1 = icmp sge <2 x i64> %x1, %y1
374   %yb = load i64, i64* %yb.ptr, align 4
375   %y.0 = insertelement <2 x i64> undef, i64 %yb, i32 0
376   %y = insertelement <2 x i64> %y.0, i64 %yb, i32 1
377   %mask0 = icmp sgt <2 x i64> %x, %y
378   %mask = select <2 x i1> %mask0, <2 x i1> %mask1, <2 x i1> zeroinitializer
379   %max = select <2 x i1> %mask, <2 x i64> %x, <2 x i64> %x1
380   ret <2 x i64> %max
381 }