1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=skx | FileCheck %s
3 ; CHECK-LABEL: test256_1
4 ; CHECK: vpcmpeqq {{.*%k[0-7]}}
5 ; CHECK: vmovdqa64 {{.*}}%k1
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
13 ; CHECK-LABEL: test256_2
14 ; CHECK: vpcmpgtq {{.*%k[0-7]}}
15 ; CHECK: vmovdqa64 {{.*}}%k1
17 define <4 x i64> @test256_2(<4 x i64> %x, <4 x i64> %y) nounwind {
18 %mask = icmp sgt <4 x i64> %x, %y
19 %max = select <4 x i1> %mask, <4 x i64> %x, <4 x i64> %y
23 ; CHECK-LABEL: @test256_3
24 ; CHECK: vpcmpled {{.*%k[0-7]}}
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
33 ; CHECK-LABEL: test256_4
34 ; CHECK: vpcmpnleuq {{.*%k[0-7]}}
35 ; CHECK: vmovdqa64 {{.*}}%k1
37 define <4 x i64> @test256_4(<4 x i64> %x, <4 x i64> %y) nounwind {
38 %mask = icmp ugt <4 x i64> %x, %y
39 %max = select <4 x i1> %mask, <4 x i64> %x, <4 x i64> %y
43 ; CHECK-LABEL: test256_5
44 ; CHECK: vpcmpeqd (%rdi){{.*%k[0-7]}}
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>* %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
54 ; CHECK-LABEL: @test256_6
55 ; CHECK: vpcmpgtd (%rdi){{.*%k[0-7]}}
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>* %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
65 ; CHECK-LABEL: @test256_7
66 ; CHECK: vpcmpled (%rdi){{.*%k[0-7]}}
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>* %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
76 ; CHECK-LABEL: @test256_8
77 ; CHECK: vpcmpleud (%rdi){{.*%k[0-7]}}
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>* %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
87 ; CHECK-LABEL: @test256_9
88 ; CHECK: vpcmpeqd %ymm{{.*{%k[1-7]}}}
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
99 ; CHECK-LABEL: @test256_10
100 ; CHECK: vpcmpleq %ymm{{.*{%k[1-7]}}}
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
111 ; CHECK-LABEL: @test256_11
112 ; CHECK: vpcmpgtq (%rdi){{.*{%k[1-7]}}}
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>* %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
124 ; CHECK-LABEL: @test256_12
125 ; CHECK: vpcmpleud (%rdi){{.*{%k[1-7]}}}
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>* %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
137 ; CHECK-LABEL: test256_13
138 ; CHECK: vpcmpeqq (%rdi){1to4}, %ymm
141 define <4 x i64> @test256_13(<4 x i64> %x, <4 x i64> %x1, i64* %yb.ptr) nounwind {
142 %yb = load 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
150 ; CHECK-LABEL: test256_14
151 ; CHECK: vpcmpled (%rdi){1to8}, %ymm
154 define <8 x i32> @test256_14(<8 x i32> %x, i32* %yb.ptr, <8 x i32> %x1) nounwind {
155 %yb = load 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
163 ; CHECK-LABEL: test256_15
164 ; CHECK: vpcmpgtd (%rdi){1to8}, %ymm{{.*{%k[1-7]}}}
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* %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
178 ; CHECK-LABEL: test256_16
179 ; CHECK: vpcmpgtq (%rdi){1to4}, %ymm{{.*{%k[1-7]}}}
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* %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
193 ; CHECK-LABEL: test128_1
194 ; CHECK: vpcmpeqq {{.*%k[0-7]}}
195 ; CHECK: vmovdqa64 {{.*}}%k1
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
203 ; CHECK-LABEL: test128_2
204 ; CHECK: vpcmpgtq {{.*%k[0-7]}}
205 ; CHECK: vmovdqa64 {{.*}}%k1
207 define <2 x i64> @test128_2(<2 x i64> %x, <2 x i64> %y) nounwind {
208 %mask = icmp sgt <2 x i64> %x, %y
209 %max = select <2 x i1> %mask, <2 x i64> %x, <2 x i64> %y
213 ; CHECK-LABEL: @test128_3
214 ; CHECK: vpcmpled {{.*%k[0-7]}}
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
223 ; CHECK-LABEL: test128_4
224 ; CHECK: vpcmpnleuq {{.*%k[0-7]}}
225 ; CHECK: vmovdqa64 {{.*}}%k1
227 define <2 x i64> @test128_4(<2 x i64> %x, <2 x i64> %y) nounwind {
228 %mask = icmp ugt <2 x i64> %x, %y
229 %max = select <2 x i1> %mask, <2 x i64> %x, <2 x i64> %y
233 ; CHECK-LABEL: test128_5
234 ; CHECK: vpcmpeqd (%rdi){{.*%k[0-7]}}
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>* %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
244 ; CHECK-LABEL: @test128_6
245 ; CHECK: vpcmpgtd (%rdi){{.*%k[0-7]}}
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>* %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
255 ; CHECK-LABEL: @test128_7
256 ; CHECK: vpcmpled (%rdi){{.*%k[0-7]}}
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>* %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
266 ; CHECK-LABEL: @test128_8
267 ; CHECK: vpcmpleud (%rdi){{.*%k[0-7]}}
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>* %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
277 ; CHECK-LABEL: @test128_9
278 ; CHECK: vpcmpeqd %xmm{{.*{%k[1-7]}}}
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
289 ; CHECK-LABEL: @test128_10
290 ; CHECK: vpcmpleq %xmm{{.*{%k[1-7]}}}
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
301 ; CHECK-LABEL: @test128_11
302 ; CHECK: vpcmpgtq (%rdi){{.*{%k[1-7]}}}
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>* %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
314 ; CHECK-LABEL: @test128_12
315 ; CHECK: vpcmpleud (%rdi){{.*{%k[1-7]}}}
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>* %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
327 ; CHECK-LABEL: test128_13
328 ; CHECK: vpcmpeqq (%rdi){1to2}, %xmm
331 define <2 x i64> @test128_13(<2 x i64> %x, <2 x i64> %x1, i64* %yb.ptr) nounwind {
332 %yb = load 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
340 ; CHECK-LABEL: test128_14
341 ; CHECK: vpcmpled (%rdi){1to4}, %xmm
344 define <4 x i32> @test128_14(<4 x i32> %x, i32* %yb.ptr, <4 x i32> %x1) nounwind {
345 %yb = load 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
353 ; CHECK-LABEL: test128_15
354 ; CHECK: vpcmpgtd (%rdi){1to4}, %xmm{{.*{%k[1-7]}}}
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* %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
368 ; CHECK-LABEL: test128_16
369 ; CHECK: vpcmpgtq (%rdi){1to2}, %xmm{{.*{%k[1-7]}}}
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* %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