1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefixes=X64,SSE
3 ; RUN: llc < %s -mtriple=x86_64-linux -mattr=avx | FileCheck %s --check-prefixes=X64,AVX,AVX1
4 ; RUN: llc < %s -mtriple=x86_64-linux -mattr=avx2 | FileCheck %s --check-prefixes=X64,AVX,AVX2
5 ; RUN: llc < %s -mtriple=i686 -mattr=cmov | FileCheck %s --check-prefix=X86
7 declare i8 @llvm.umax.i8(i8, i8)
8 declare i16 @llvm.umax.i16(i16, i16)
9 declare i24 @llvm.umax.i24(i24, i24)
10 declare i32 @llvm.umax.i32(i32, i32)
11 declare i64 @llvm.umax.i64(i64, i64)
12 declare i128 @llvm.umax.i128(i128, i128)
14 declare <1 x i32> @llvm.umax.v1i32(<1 x i32>, <1 x i32>)
15 declare <2 x i32> @llvm.umax.v2i32(<2 x i32>, <2 x i32>)
16 declare <3 x i32> @llvm.umax.v3i32(<3 x i32>, <3 x i32>)
17 declare <4 x i32> @llvm.umax.v4i32(<4 x i32>, <4 x i32>)
18 declare <8 x i32> @llvm.umax.v8i32(<8 x i32>, <8 x i32>)
20 declare <2 x i64> @llvm.umax.v2i64(<2 x i64>, <2 x i64>)
21 declare <8 x i16> @llvm.umax.v8i16(<8 x i16>, <8 x i16>)
22 declare <16 x i8> @llvm.umax.v16i8(<16 x i8>, <16 x i8>)
24 define i8 @test_i8(i8 %a, i8 %b) nounwind {
27 ; X64-NEXT: movl %esi, %eax
28 ; X64-NEXT: cmpb %al, %dil
29 ; X64-NEXT: cmoval %edi, %eax
30 ; X64-NEXT: # kill: def $al killed $al killed $eax
35 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
36 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
37 ; X86-NEXT: cmpb %al, %cl
38 ; X86-NEXT: cmoval %ecx, %eax
39 ; X86-NEXT: # kill: def $al killed $al killed $eax
41 %r = call i8 @llvm.umax.i8(i8 %a, i8 %b)
45 define i8 @test_i8_1(i8 %a) nounwind {
46 ; X64-LABEL: test_i8_1:
48 ; X64-NEXT: movl %edi, %eax
49 ; X64-NEXT: cmpb $1, %al
50 ; X64-NEXT: adcl $0, %eax
51 ; X64-NEXT: # kill: def $al killed $al killed $eax
54 ; X86-LABEL: test_i8_1:
56 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
57 ; X86-NEXT: cmpb $1, %al
58 ; X86-NEXT: adcl $0, %eax
59 ; X86-NEXT: # kill: def $al killed $al killed $eax
61 %r = call i8 @llvm.umax.i8(i8 %a, i8 1)
65 define i16 @test_i16(i16 %a, i16 %b) nounwind {
66 ; X64-LABEL: test_i16:
68 ; X64-NEXT: movl %esi, %eax
69 ; X64-NEXT: cmpw %ax, %di
70 ; X64-NEXT: cmoval %edi, %eax
71 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
74 ; X86-LABEL: test_i16:
76 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
77 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
78 ; X86-NEXT: cmpw %ax, %cx
79 ; X86-NEXT: cmoval %ecx, %eax
80 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
82 %r = call i16 @llvm.umax.i16(i16 %a, i16 %b)
86 define i16 @test_i16_1(i16 %a) nounwind {
87 ; X64-LABEL: test_i16_1:
89 ; X64-NEXT: movl %edi, %eax
90 ; X64-NEXT: cmpw $1, %ax
91 ; X64-NEXT: adcl $0, %eax
92 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
95 ; X86-LABEL: test_i16_1:
97 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
98 ; X86-NEXT: cmpw $1, %ax
99 ; X86-NEXT: adcl $0, %eax
100 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
102 %r = call i16 @llvm.umax.i16(i16 %a, i16 1)
106 define i24 @test_i24(i24 %a, i24 %b) nounwind {
107 ; X64-LABEL: test_i24:
109 ; X64-NEXT: movl %edi, %eax
110 ; X64-NEXT: andl $16777215, %esi # imm = 0xFFFFFF
111 ; X64-NEXT: andl $16777215, %eax # imm = 0xFFFFFF
112 ; X64-NEXT: cmpl %esi, %eax
113 ; X64-NEXT: cmovbel %esi, %eax
116 ; X86-LABEL: test_i24:
118 ; X86-NEXT: movl $16777215, %eax # imm = 0xFFFFFF
119 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
120 ; X86-NEXT: andl %eax, %ecx
121 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
122 ; X86-NEXT: cmpl %ecx, %eax
123 ; X86-NEXT: cmovbel %ecx, %eax
125 %r = call i24 @llvm.umax.i24(i24 %a, i24 %b)
129 define i32 @test_i32(i32 %a, i32 %b) nounwind {
130 ; X64-LABEL: test_i32:
132 ; X64-NEXT: movl %esi, %eax
133 ; X64-NEXT: cmpl %esi, %edi
134 ; X64-NEXT: cmoval %edi, %eax
137 ; X86-LABEL: test_i32:
139 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
140 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
141 ; X86-NEXT: cmpl %eax, %ecx
142 ; X86-NEXT: cmoval %ecx, %eax
144 %r = call i32 @llvm.umax.i32(i32 %a, i32 %b)
148 define i32 @test_i32_1(i32 %a) nounwind {
149 ; X64-LABEL: test_i32_1:
151 ; X64-NEXT: movl %edi, %eax
152 ; X64-NEXT: cmpl $1, %edi
153 ; X64-NEXT: adcl $0, %eax
156 ; X86-LABEL: test_i32_1:
158 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
159 ; X86-NEXT: cmpl $1, %eax
160 ; X86-NEXT: adcl $0, %eax
162 %r = call i32 @llvm.umax.i32(i32 %a, i32 1)
166 define i64 @test_i64(i64 %a, i64 %b) nounwind {
167 ; X64-LABEL: test_i64:
169 ; X64-NEXT: movq %rsi, %rax
170 ; X64-NEXT: cmpq %rsi, %rdi
171 ; X64-NEXT: cmovaq %rdi, %rax
174 ; X86-LABEL: test_i64:
176 ; X86-NEXT: pushl %edi
177 ; X86-NEXT: pushl %esi
178 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
179 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
180 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
181 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
182 ; X86-NEXT: cmpl %ecx, %eax
183 ; X86-NEXT: movl %edx, %edi
184 ; X86-NEXT: sbbl %esi, %edi
185 ; X86-NEXT: cmovbl %ecx, %eax
186 ; X86-NEXT: cmovbl %esi, %edx
187 ; X86-NEXT: popl %esi
188 ; X86-NEXT: popl %edi
190 %r = call i64 @llvm.umax.i64(i64 %a, i64 %b)
194 define i64 @test_i64_1(i64 %a) nounwind {
195 ; X64-LABEL: test_i64_1:
197 ; X64-NEXT: movq %rdi, %rax
198 ; X64-NEXT: cmpq $1, %rdi
199 ; X64-NEXT: adcq $0, %rax
202 ; X86-LABEL: test_i64_1:
204 ; X86-NEXT: pushl %esi
205 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
206 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
207 ; X86-NEXT: cmpl $1, %ecx
208 ; X86-NEXT: movl %ecx, %esi
209 ; X86-NEXT: adcl $0, %esi
210 ; X86-NEXT: testl %edx, %edx
211 ; X86-NEXT: movl $1, %eax
212 ; X86-NEXT: cmovnel %ecx, %eax
213 ; X86-NEXT: cmovel %esi, %eax
214 ; X86-NEXT: popl %esi
216 %r = call i64 @llvm.umax.i64(i64 %a, i64 1)
220 define i128 @test_i128(i128 %a, i128 %b) nounwind {
221 ; X64-LABEL: test_i128:
223 ; X64-NEXT: movq %rdx, %rax
224 ; X64-NEXT: cmpq %rdi, %rdx
225 ; X64-NEXT: movq %rcx, %rdx
226 ; X64-NEXT: sbbq %rsi, %rdx
227 ; X64-NEXT: cmovbq %rdi, %rax
228 ; X64-NEXT: cmovbq %rsi, %rcx
229 ; X64-NEXT: movq %rcx, %rdx
232 ; X86-LABEL: test_i128:
234 ; X86-NEXT: pushl %ebp
235 ; X86-NEXT: pushl %ebx
236 ; X86-NEXT: pushl %edi
237 ; X86-NEXT: pushl %esi
238 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
239 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
240 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
241 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
242 ; X86-NEXT: cmpl %ebx, %edx
243 ; X86-NEXT: movl %esi, %ebp
244 ; X86-NEXT: sbbl {{[0-9]+}}(%esp), %ebp
245 ; X86-NEXT: movl %edi, %ebp
246 ; X86-NEXT: sbbl {{[0-9]+}}(%esp), %ebp
247 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
248 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
249 ; X86-NEXT: movl %ecx, %eax
250 ; X86-NEXT: sbbl %ebp, %eax
251 ; X86-NEXT: cmovbl %ebx, %edx
252 ; X86-NEXT: cmovbl {{[0-9]+}}(%esp), %esi
253 ; X86-NEXT: cmovbl {{[0-9]+}}(%esp), %edi
254 ; X86-NEXT: cmovbl %ebp, %ecx
255 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
256 ; X86-NEXT: movl %ecx, 12(%eax)
257 ; X86-NEXT: movl %edi, 8(%eax)
258 ; X86-NEXT: movl %esi, 4(%eax)
259 ; X86-NEXT: movl %edx, (%eax)
260 ; X86-NEXT: popl %esi
261 ; X86-NEXT: popl %edi
262 ; X86-NEXT: popl %ebx
263 ; X86-NEXT: popl %ebp
265 %r = call i128 @llvm.umax.i128(i128 %a, i128 %b)
269 define i128 @test_i128_1(i128 %a) nounwind {
270 ; X64-LABEL: test_i128_1:
272 ; X64-NEXT: movq %rsi, %rdx
273 ; X64-NEXT: cmpq $1, %rdi
274 ; X64-NEXT: movq %rdi, %rcx
275 ; X64-NEXT: adcq $0, %rcx
276 ; X64-NEXT: testq %rsi, %rsi
277 ; X64-NEXT: movl $1, %eax
278 ; X64-NEXT: cmovneq %rdi, %rax
279 ; X64-NEXT: cmoveq %rcx, %rax
282 ; X86-LABEL: test_i128_1:
284 ; X86-NEXT: pushl %ebp
285 ; X86-NEXT: pushl %ebx
286 ; X86-NEXT: pushl %edi
287 ; X86-NEXT: pushl %esi
288 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
289 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
290 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
291 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
292 ; X86-NEXT: cmpl $1, %eax
293 ; X86-NEXT: movl %eax, %ebx
294 ; X86-NEXT: adcl $0, %ebx
295 ; X86-NEXT: testl %edx, %edx
296 ; X86-NEXT: movl $1, %edi
297 ; X86-NEXT: cmovnel %eax, %edi
298 ; X86-NEXT: cmovel %ebx, %edi
299 ; X86-NEXT: xorl %ebx, %ebx
300 ; X86-NEXT: movl %ecx, %ebp
301 ; X86-NEXT: negl %ebp
302 ; X86-NEXT: movl $0, %ebp
303 ; X86-NEXT: sbbl %esi, %ebp
304 ; X86-NEXT: movl $1, %ebp
305 ; X86-NEXT: cmovbl %eax, %ebp
306 ; X86-NEXT: movl %ecx, %eax
307 ; X86-NEXT: cmovbl %edx, %ebx
308 ; X86-NEXT: orl %esi, %eax
309 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
310 ; X86-NEXT: movl %esi, 12(%eax)
311 ; X86-NEXT: movl %ecx, 8(%eax)
312 ; X86-NEXT: cmovel %edi, %ebp
313 ; X86-NEXT: cmovel %edx, %ebx
314 ; X86-NEXT: movl %ebx, 4(%eax)
315 ; X86-NEXT: movl %ebp, (%eax)
316 ; X86-NEXT: popl %esi
317 ; X86-NEXT: popl %edi
318 ; X86-NEXT: popl %ebx
319 ; X86-NEXT: popl %ebp
321 %r = call i128 @llvm.umax.i128(i128 %a, i128 1)
325 define <2 x i64> @test_v2i64(<2 x i64> %a, <2 x i64> %b) nounwind {
326 ; SSE-LABEL: test_v2i64:
328 ; SSE-NEXT: movdqa {{.*#+}} xmm2 = [9223372039002259456,9223372039002259456]
329 ; SSE-NEXT: movdqa %xmm1, %xmm3
330 ; SSE-NEXT: pxor %xmm2, %xmm3
331 ; SSE-NEXT: pxor %xmm0, %xmm2
332 ; SSE-NEXT: movdqa %xmm2, %xmm4
333 ; SSE-NEXT: pcmpgtd %xmm3, %xmm4
334 ; SSE-NEXT: pshufd {{.*#+}} xmm5 = xmm4[0,0,2,2]
335 ; SSE-NEXT: pcmpeqd %xmm3, %xmm2
336 ; SSE-NEXT: pshufd {{.*#+}} xmm2 = xmm2[1,1,3,3]
337 ; SSE-NEXT: pand %xmm5, %xmm2
338 ; SSE-NEXT: pshufd {{.*#+}} xmm3 = xmm4[1,1,3,3]
339 ; SSE-NEXT: por %xmm2, %xmm3
340 ; SSE-NEXT: pand %xmm3, %xmm0
341 ; SSE-NEXT: pandn %xmm1, %xmm3
342 ; SSE-NEXT: por %xmm3, %xmm0
345 ; AVX1-LABEL: test_v2i64:
347 ; AVX1-NEXT: vmovddup {{.*#+}} xmm2 = [9223372036854775808,9223372036854775808]
348 ; AVX1-NEXT: # xmm2 = mem[0,0]
349 ; AVX1-NEXT: vpxor %xmm2, %xmm1, %xmm3
350 ; AVX1-NEXT: vpxor %xmm2, %xmm0, %xmm2
351 ; AVX1-NEXT: vpcmpgtq %xmm3, %xmm2, %xmm2
352 ; AVX1-NEXT: vblendvpd %xmm2, %xmm0, %xmm1, %xmm0
355 ; AVX2-LABEL: test_v2i64:
357 ; AVX2-NEXT: vpbroadcastq {{.*#+}} xmm2 = [9223372036854775808,9223372036854775808]
358 ; AVX2-NEXT: vpxor %xmm2, %xmm1, %xmm3
359 ; AVX2-NEXT: vpxor %xmm2, %xmm0, %xmm2
360 ; AVX2-NEXT: vpcmpgtq %xmm3, %xmm2, %xmm2
361 ; AVX2-NEXT: vblendvpd %xmm2, %xmm0, %xmm1, %xmm0
364 ; X86-LABEL: test_v2i64:
366 ; X86-NEXT: pushl %ebp
367 ; X86-NEXT: pushl %ebx
368 ; X86-NEXT: pushl %edi
369 ; X86-NEXT: pushl %esi
370 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
371 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
372 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
373 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
374 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
375 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
376 ; X86-NEXT: cmpl %ebx, %ecx
377 ; X86-NEXT: movl %esi, %edi
378 ; X86-NEXT: sbbl %ebp, %edi
379 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
380 ; X86-NEXT: cmovbl %ebx, %ecx
381 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
382 ; X86-NEXT: cmovbl %ebp, %esi
383 ; X86-NEXT: cmpl %edx, %edi
384 ; X86-NEXT: movl %ebx, %ebp
385 ; X86-NEXT: sbbl %eax, %ebp
386 ; X86-NEXT: cmovbl %edx, %edi
387 ; X86-NEXT: cmovbl %eax, %ebx
388 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
389 ; X86-NEXT: movl %ebx, 12(%eax)
390 ; X86-NEXT: movl %edi, 8(%eax)
391 ; X86-NEXT: movl %esi, 4(%eax)
392 ; X86-NEXT: movl %ecx, (%eax)
393 ; X86-NEXT: popl %esi
394 ; X86-NEXT: popl %edi
395 ; X86-NEXT: popl %ebx
396 ; X86-NEXT: popl %ebp
398 %r = call <2 x i64> @llvm.umax.v2i64(<2 x i64> %a, <2 x i64> %b)
402 define <2 x i64> @test_v2i64_1(<2 x i64> %a) nounwind {
403 ; SSE-LABEL: test_v2i64_1:
405 ; SSE-NEXT: pxor %xmm1, %xmm1
406 ; SSE-NEXT: pcmpeqd %xmm0, %xmm1
407 ; SSE-NEXT: pshufd {{.*#+}} xmm2 = xmm1[1,0,3,2]
408 ; SSE-NEXT: pand %xmm1, %xmm2
409 ; SSE-NEXT: psubq %xmm2, %xmm0
412 ; AVX-LABEL: test_v2i64_1:
414 ; AVX-NEXT: vpxor %xmm1, %xmm1, %xmm1
415 ; AVX-NEXT: vpcmpeqq %xmm1, %xmm0, %xmm1
416 ; AVX-NEXT: vpsubq %xmm1, %xmm0, %xmm0
419 ; X86-LABEL: test_v2i64_1:
421 ; X86-NEXT: pushl %ebp
422 ; X86-NEXT: pushl %ebx
423 ; X86-NEXT: pushl %edi
424 ; X86-NEXT: pushl %esi
425 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
426 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
427 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
428 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
429 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
430 ; X86-NEXT: cmpl $1, %ecx
431 ; X86-NEXT: movl %ecx, %ebx
432 ; X86-NEXT: adcl $0, %ebx
433 ; X86-NEXT: testl %esi, %esi
434 ; X86-NEXT: movl $1, %ebp
435 ; X86-NEXT: cmovel %ebp, %ecx
436 ; X86-NEXT: cmovel %ebx, %ecx
437 ; X86-NEXT: cmpl $1, %edi
438 ; X86-NEXT: movl %edi, %ebx
439 ; X86-NEXT: adcl $0, %ebx
440 ; X86-NEXT: testl %edx, %edx
441 ; X86-NEXT: cmovnel %edi, %ebp
442 ; X86-NEXT: cmovel %ebx, %ebp
443 ; X86-NEXT: movl %edx, 12(%eax)
444 ; X86-NEXT: movl %ebp, 8(%eax)
445 ; X86-NEXT: movl %esi, 4(%eax)
446 ; X86-NEXT: movl %ecx, (%eax)
447 ; X86-NEXT: popl %esi
448 ; X86-NEXT: popl %edi
449 ; X86-NEXT: popl %ebx
450 ; X86-NEXT: popl %ebp
452 %r = call <2 x i64> @llvm.umax.v2i64(<2 x i64> %a, <2 x i64> <i64 1, i64 1>)
456 define <1 x i32> @test_v1i32(<1 x i32> %a, <1 x i32> %b) nounwind {
457 ; X64-LABEL: test_v1i32:
459 ; X64-NEXT: movl %esi, %eax
460 ; X64-NEXT: cmpl %esi, %edi
461 ; X64-NEXT: cmoval %edi, %eax
464 ; X86-LABEL: test_v1i32:
466 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
467 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
468 ; X86-NEXT: cmpl %eax, %ecx
469 ; X86-NEXT: cmoval %ecx, %eax
471 %r = call <1 x i32> @llvm.umax.v1i32(<1 x i32> %a, <1 x i32> %b)
475 define <2 x i32> @test_v2i32(<2 x i32> %a, <2 x i32> %b) nounwind {
476 ; SSE-LABEL: test_v2i32:
478 ; SSE-NEXT: movdqa {{.*#+}} xmm2 = [2147483648,2147483648,2147483648,2147483648]
479 ; SSE-NEXT: movdqa %xmm1, %xmm3
480 ; SSE-NEXT: pxor %xmm2, %xmm3
481 ; SSE-NEXT: pxor %xmm0, %xmm2
482 ; SSE-NEXT: pcmpgtd %xmm3, %xmm2
483 ; SSE-NEXT: pand %xmm2, %xmm0
484 ; SSE-NEXT: pandn %xmm1, %xmm2
485 ; SSE-NEXT: por %xmm2, %xmm0
488 ; AVX-LABEL: test_v2i32:
490 ; AVX-NEXT: vpmaxud %xmm1, %xmm0, %xmm0
493 ; X86-LABEL: test_v2i32:
495 ; X86-NEXT: pushl %esi
496 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
497 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
498 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
499 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
500 ; X86-NEXT: cmpl %eax, %esi
501 ; X86-NEXT: cmoval %esi, %eax
502 ; X86-NEXT: cmpl %edx, %ecx
503 ; X86-NEXT: cmoval %ecx, %edx
504 ; X86-NEXT: popl %esi
506 %r = call <2 x i32> @llvm.umax.v2i32(<2 x i32> %a, <2 x i32> %b)
510 define <3 x i32> @test_v3i32(<3 x i32> %a, <3 x i32> %b) nounwind {
511 ; SSE-LABEL: test_v3i32:
513 ; SSE-NEXT: movdqa {{.*#+}} xmm2 = [2147483648,2147483648,2147483648,2147483648]
514 ; SSE-NEXT: movdqa %xmm1, %xmm3
515 ; SSE-NEXT: pxor %xmm2, %xmm3
516 ; SSE-NEXT: pxor %xmm0, %xmm2
517 ; SSE-NEXT: pcmpgtd %xmm3, %xmm2
518 ; SSE-NEXT: pand %xmm2, %xmm0
519 ; SSE-NEXT: pandn %xmm1, %xmm2
520 ; SSE-NEXT: por %xmm2, %xmm0
523 ; AVX-LABEL: test_v3i32:
525 ; AVX-NEXT: vpmaxud %xmm1, %xmm0, %xmm0
528 ; X86-LABEL: test_v3i32:
530 ; X86-NEXT: pushl %ebx
531 ; X86-NEXT: pushl %edi
532 ; X86-NEXT: pushl %esi
533 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
534 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
535 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
536 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
537 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
538 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
539 ; X86-NEXT: cmpl %eax, %ebx
540 ; X86-NEXT: cmoval %ebx, %eax
541 ; X86-NEXT: cmpl %edx, %edi
542 ; X86-NEXT: cmoval %edi, %edx
543 ; X86-NEXT: cmpl %ecx, %esi
544 ; X86-NEXT: cmoval %esi, %ecx
545 ; X86-NEXT: popl %esi
546 ; X86-NEXT: popl %edi
547 ; X86-NEXT: popl %ebx
549 %r = call <3 x i32> @llvm.umax.v3i32(<3 x i32> %a, <3 x i32> %b)
553 define <4 x i32> @test_v4i32(<4 x i32> %a, <4 x i32> %b) nounwind {
554 ; SSE-LABEL: test_v4i32:
556 ; SSE-NEXT: movdqa {{.*#+}} xmm2 = [2147483648,2147483648,2147483648,2147483648]
557 ; SSE-NEXT: movdqa %xmm1, %xmm3
558 ; SSE-NEXT: pxor %xmm2, %xmm3
559 ; SSE-NEXT: pxor %xmm0, %xmm2
560 ; SSE-NEXT: pcmpgtd %xmm3, %xmm2
561 ; SSE-NEXT: pand %xmm2, %xmm0
562 ; SSE-NEXT: pandn %xmm1, %xmm2
563 ; SSE-NEXT: por %xmm2, %xmm0
566 ; AVX-LABEL: test_v4i32:
568 ; AVX-NEXT: vpmaxud %xmm1, %xmm0, %xmm0
571 ; X86-LABEL: test_v4i32:
573 ; X86-NEXT: pushl %edi
574 ; X86-NEXT: pushl %esi
575 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
576 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
577 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
578 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
579 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
580 ; X86-NEXT: cmpl %edi, %eax
581 ; X86-NEXT: cmoval %eax, %edi
582 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
583 ; X86-NEXT: cmpl %esi, %eax
584 ; X86-NEXT: cmoval %eax, %esi
585 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
586 ; X86-NEXT: cmpl %edx, %eax
587 ; X86-NEXT: cmoval %eax, %edx
588 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
589 ; X86-NEXT: cmpl %ecx, %eax
590 ; X86-NEXT: cmoval %eax, %ecx
591 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
592 ; X86-NEXT: movl %ecx, 12(%eax)
593 ; X86-NEXT: movl %edx, 8(%eax)
594 ; X86-NEXT: movl %esi, 4(%eax)
595 ; X86-NEXT: movl %edi, (%eax)
596 ; X86-NEXT: popl %esi
597 ; X86-NEXT: popl %edi
599 %r = call <4 x i32> @llvm.umax.v4i32(<4 x i32> %a, <4 x i32> %b)
603 define <4 x i32> @test_v4i32_1(<4 x i32> %a) nounwind {
604 ; SSE-LABEL: test_v4i32_1:
606 ; SSE-NEXT: pxor %xmm1, %xmm1
607 ; SSE-NEXT: pcmpeqd %xmm0, %xmm1
608 ; SSE-NEXT: psubd %xmm1, %xmm0
611 ; AVX1-LABEL: test_v4i32_1:
613 ; AVX1-NEXT: vpmaxud {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
616 ; AVX2-LABEL: test_v4i32_1:
618 ; AVX2-NEXT: vpbroadcastd {{.*#+}} xmm1 = [1,1,1,1]
619 ; AVX2-NEXT: vpmaxud %xmm1, %xmm0, %xmm0
622 ; X86-LABEL: test_v4i32_1:
624 ; X86-NEXT: pushl %edi
625 ; X86-NEXT: pushl %esi
626 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
627 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
628 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
629 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
630 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
631 ; X86-NEXT: cmpl $1, %ecx
632 ; X86-NEXT: adcl $0, %ecx
633 ; X86-NEXT: cmpl $1, %edx
634 ; X86-NEXT: adcl $0, %edx
635 ; X86-NEXT: cmpl $1, %esi
636 ; X86-NEXT: adcl $0, %esi
637 ; X86-NEXT: cmpl $1, %edi
638 ; X86-NEXT: adcl $0, %edi
639 ; X86-NEXT: movl %edi, 12(%eax)
640 ; X86-NEXT: movl %esi, 8(%eax)
641 ; X86-NEXT: movl %edx, 4(%eax)
642 ; X86-NEXT: movl %ecx, (%eax)
643 ; X86-NEXT: popl %esi
644 ; X86-NEXT: popl %edi
646 %r = call <4 x i32> @llvm.umax.v4i32(<4 x i32> %a, <4 x i32> <i32 1, i32 1, i32 1, i32 1>)
650 define <8 x i32> @test_v8i32(<8 x i32> %a, <8 x i32> %b) nounwind {
651 ; SSE-LABEL: test_v8i32:
653 ; SSE-NEXT: movdqa {{.*#+}} xmm4 = [2147483648,2147483648,2147483648,2147483648]
654 ; SSE-NEXT: movdqa %xmm2, %xmm5
655 ; SSE-NEXT: pxor %xmm4, %xmm5
656 ; SSE-NEXT: movdqa %xmm0, %xmm6
657 ; SSE-NEXT: pxor %xmm4, %xmm6
658 ; SSE-NEXT: pcmpgtd %xmm5, %xmm6
659 ; SSE-NEXT: pand %xmm6, %xmm0
660 ; SSE-NEXT: pandn %xmm2, %xmm6
661 ; SSE-NEXT: por %xmm6, %xmm0
662 ; SSE-NEXT: movdqa %xmm3, %xmm2
663 ; SSE-NEXT: pxor %xmm4, %xmm2
664 ; SSE-NEXT: pxor %xmm1, %xmm4
665 ; SSE-NEXT: pcmpgtd %xmm2, %xmm4
666 ; SSE-NEXT: pand %xmm4, %xmm1
667 ; SSE-NEXT: pandn %xmm3, %xmm4
668 ; SSE-NEXT: por %xmm4, %xmm1
671 ; AVX1-LABEL: test_v8i32:
673 ; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm2
674 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm3
675 ; AVX1-NEXT: vpmaxud %xmm2, %xmm3, %xmm2
676 ; AVX1-NEXT: vpmaxud %xmm1, %xmm0, %xmm0
677 ; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0
680 ; AVX2-LABEL: test_v8i32:
682 ; AVX2-NEXT: vpmaxud %ymm1, %ymm0, %ymm0
685 ; X86-LABEL: test_v8i32:
687 ; X86-NEXT: pushl %ebp
688 ; X86-NEXT: pushl %ebx
689 ; X86-NEXT: pushl %edi
690 ; X86-NEXT: pushl %esi
691 ; X86-NEXT: subl $8, %esp
692 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
693 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
694 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
695 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
696 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
697 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
698 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
699 ; X86-NEXT: cmpl %ebp, %eax
700 ; X86-NEXT: cmoval %eax, %ebp
701 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
702 ; X86-NEXT: cmpl %ebx, %eax
703 ; X86-NEXT: cmoval %eax, %ebx
704 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
705 ; X86-NEXT: cmpl %edi, %eax
706 ; X86-NEXT: cmoval %eax, %edi
707 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
708 ; X86-NEXT: cmpl %esi, %eax
709 ; X86-NEXT: cmoval %eax, %esi
710 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
711 ; X86-NEXT: cmpl %edx, %eax
712 ; X86-NEXT: cmoval %eax, %edx
713 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
714 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
715 ; X86-NEXT: cmpl %ecx, %eax
716 ; X86-NEXT: cmoval %eax, %ecx
717 ; X86-NEXT: movl %ecx, (%esp) # 4-byte Spill
718 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
719 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
720 ; X86-NEXT: cmpl %edx, %eax
721 ; X86-NEXT: cmoval %eax, %edx
722 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
723 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
724 ; X86-NEXT: cmpl %eax, %ecx
725 ; X86-NEXT: cmoval %ecx, %eax
726 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
727 ; X86-NEXT: movl %eax, 28(%ecx)
728 ; X86-NEXT: movl %edx, 24(%ecx)
729 ; X86-NEXT: movl (%esp), %eax # 4-byte Reload
730 ; X86-NEXT: movl %eax, 20(%ecx)
731 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
732 ; X86-NEXT: movl %eax, 16(%ecx)
733 ; X86-NEXT: movl %esi, 12(%ecx)
734 ; X86-NEXT: movl %edi, 8(%ecx)
735 ; X86-NEXT: movl %ebx, 4(%ecx)
736 ; X86-NEXT: movl %ebp, (%ecx)
737 ; X86-NEXT: movl %ecx, %eax
738 ; X86-NEXT: addl $8, %esp
739 ; X86-NEXT: popl %esi
740 ; X86-NEXT: popl %edi
741 ; X86-NEXT: popl %ebx
742 ; X86-NEXT: popl %ebp
744 %r = call <8 x i32> @llvm.umax.v8i32(<8 x i32> %a, <8 x i32> %b)
748 define <8 x i32> @test_v8i32_1(<8 x i32> %a) nounwind {
749 ; SSE-LABEL: test_v8i32_1:
751 ; SSE-NEXT: pxor %xmm2, %xmm2
752 ; SSE-NEXT: movdqa %xmm0, %xmm3
753 ; SSE-NEXT: pcmpeqd %xmm2, %xmm3
754 ; SSE-NEXT: psubd %xmm3, %xmm0
755 ; SSE-NEXT: pcmpeqd %xmm1, %xmm2
756 ; SSE-NEXT: psubd %xmm2, %xmm1
759 ; AVX1-LABEL: test_v8i32_1:
761 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1
762 ; AVX1-NEXT: vbroadcastss {{.*#+}} xmm2 = [1,1,1,1]
763 ; AVX1-NEXT: vpmaxud %xmm2, %xmm1, %xmm1
764 ; AVX1-NEXT: vpmaxud %xmm2, %xmm0, %xmm0
765 ; AVX1-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
768 ; AVX2-LABEL: test_v8i32_1:
770 ; AVX2-NEXT: vpbroadcastd {{.*#+}} ymm1 = [1,1,1,1,1,1,1,1]
771 ; AVX2-NEXT: vpmaxud %ymm1, %ymm0, %ymm0
774 ; X86-LABEL: test_v8i32_1:
776 ; X86-NEXT: pushl %ebp
777 ; X86-NEXT: pushl %ebx
778 ; X86-NEXT: pushl %edi
779 ; X86-NEXT: pushl %esi
780 ; X86-NEXT: subl $8, %esp
781 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
782 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
783 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
784 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
785 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
786 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
787 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
788 ; X86-NEXT: cmpl $1, %eax
789 ; X86-NEXT: adcl $0, %eax
790 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
791 ; X86-NEXT: cmpl $1, %edx
792 ; X86-NEXT: adcl $0, %edx
793 ; X86-NEXT: cmpl $1, %esi
794 ; X86-NEXT: adcl $0, %esi
795 ; X86-NEXT: cmpl $1, %edi
796 ; X86-NEXT: adcl $0, %edi
797 ; X86-NEXT: cmpl $1, %ebx
798 ; X86-NEXT: adcl $0, %ebx
799 ; X86-NEXT: cmpl $1, %ebp
800 ; X86-NEXT: adcl $0, %ebp
801 ; X86-NEXT: cmpl $1, %ecx
802 ; X86-NEXT: adcl $0, %ecx
803 ; X86-NEXT: movl %ecx, (%esp) # 4-byte Spill
804 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
805 ; X86-NEXT: cmpl $1, %eax
806 ; X86-NEXT: adcl $0, %eax
807 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
808 ; X86-NEXT: movl %eax, 28(%ecx)
809 ; X86-NEXT: movl (%esp), %eax # 4-byte Reload
810 ; X86-NEXT: movl %eax, 24(%ecx)
811 ; X86-NEXT: movl %ebp, 20(%ecx)
812 ; X86-NEXT: movl %ebx, 16(%ecx)
813 ; X86-NEXT: movl %edi, 12(%ecx)
814 ; X86-NEXT: movl %esi, 8(%ecx)
815 ; X86-NEXT: movl %edx, 4(%ecx)
816 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
817 ; X86-NEXT: movl %eax, (%ecx)
818 ; X86-NEXT: movl %ecx, %eax
819 ; X86-NEXT: addl $8, %esp
820 ; X86-NEXT: popl %esi
821 ; X86-NEXT: popl %edi
822 ; X86-NEXT: popl %ebx
823 ; X86-NEXT: popl %ebp
825 %r = call <8 x i32> @llvm.umax.v8i32(<8 x i32> %a, <8 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>)
829 define <8 x i16> @test_v8i16(<8 x i16> %a, <8 x i16> %b) nounwind {
830 ; SSE-LABEL: test_v8i16:
832 ; SSE-NEXT: psubusw %xmm0, %xmm1
833 ; SSE-NEXT: paddw %xmm1, %xmm0
836 ; AVX-LABEL: test_v8i16:
838 ; AVX-NEXT: vpmaxuw %xmm1, %xmm0, %xmm0
841 ; X86-LABEL: test_v8i16:
843 ; X86-NEXT: pushl %ebp
844 ; X86-NEXT: pushl %ebx
845 ; X86-NEXT: pushl %edi
846 ; X86-NEXT: pushl %esi
847 ; X86-NEXT: subl $8, %esp
848 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
849 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
850 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
851 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
852 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
853 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
854 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
855 ; X86-NEXT: cmpw %bp, %ax
856 ; X86-NEXT: cmoval %eax, %ebp
857 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
858 ; X86-NEXT: cmpw %bx, %ax
859 ; X86-NEXT: cmoval %eax, %ebx
860 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
861 ; X86-NEXT: cmpw %di, %ax
862 ; X86-NEXT: cmoval %eax, %edi
863 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
864 ; X86-NEXT: cmpw %si, %ax
865 ; X86-NEXT: cmoval %eax, %esi
866 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
867 ; X86-NEXT: cmpw %dx, %ax
868 ; X86-NEXT: cmoval %eax, %edx
869 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
870 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
871 ; X86-NEXT: cmpw %cx, %ax
872 ; X86-NEXT: cmoval %eax, %ecx
873 ; X86-NEXT: movl %ecx, (%esp) # 4-byte Spill
874 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
875 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
876 ; X86-NEXT: cmpw %dx, %ax
877 ; X86-NEXT: cmoval %eax, %edx
878 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
879 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
880 ; X86-NEXT: cmpw %ax, %cx
881 ; X86-NEXT: cmoval %ecx, %eax
882 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
883 ; X86-NEXT: movw %ax, 14(%ecx)
884 ; X86-NEXT: movw %dx, 12(%ecx)
885 ; X86-NEXT: movl (%esp), %eax # 4-byte Reload
886 ; X86-NEXT: movw %ax, 10(%ecx)
887 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
888 ; X86-NEXT: movw %ax, 8(%ecx)
889 ; X86-NEXT: movw %si, 6(%ecx)
890 ; X86-NEXT: movw %di, 4(%ecx)
891 ; X86-NEXT: movw %bx, 2(%ecx)
892 ; X86-NEXT: movw %bp, (%ecx)
893 ; X86-NEXT: movl %ecx, %eax
894 ; X86-NEXT: addl $8, %esp
895 ; X86-NEXT: popl %esi
896 ; X86-NEXT: popl %edi
897 ; X86-NEXT: popl %ebx
898 ; X86-NEXT: popl %ebp
900 %r = call <8 x i16> @llvm.umax.v8i16(<8 x i16> %a, <8 x i16> %b)
904 define <8 x i16> @test_v8i16_1(<8 x i16> %a) nounwind {
905 ; SSE-LABEL: test_v8i16_1:
907 ; SSE-NEXT: pxor %xmm1, %xmm1
908 ; SSE-NEXT: pcmpeqw %xmm0, %xmm1
909 ; SSE-NEXT: psubw %xmm1, %xmm0
912 ; AVX-LABEL: test_v8i16_1:
914 ; AVX-NEXT: vpmaxuw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
917 ; X86-LABEL: test_v8i16_1:
919 ; X86-NEXT: pushl %ebp
920 ; X86-NEXT: pushl %ebx
921 ; X86-NEXT: pushl %edi
922 ; X86-NEXT: pushl %esi
923 ; X86-NEXT: subl $8, %esp
924 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
925 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
926 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
927 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
928 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
929 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
930 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
931 ; X86-NEXT: cmpw $1, %dx
932 ; X86-NEXT: adcl $0, %edx
933 ; X86-NEXT: cmpw $1, %bp
934 ; X86-NEXT: adcl $0, %ebp
935 ; X86-NEXT: cmpw $1, %bx
936 ; X86-NEXT: adcl $0, %ebx
937 ; X86-NEXT: cmpw $1, %di
938 ; X86-NEXT: adcl $0, %edi
939 ; X86-NEXT: cmpw $1, %si
940 ; X86-NEXT: adcl $0, %esi
941 ; X86-NEXT: cmpw $1, %cx
942 ; X86-NEXT: adcl $0, %ecx
943 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
944 ; X86-NEXT: cmpw $1, %ax
945 ; X86-NEXT: adcl $0, %eax
946 ; X86-NEXT: movl %eax, (%esp) # 4-byte Spill
947 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
948 ; X86-NEXT: cmpw $1, %ax
949 ; X86-NEXT: adcl $0, %eax
950 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
951 ; X86-NEXT: movw %ax, 14(%ecx)
952 ; X86-NEXT: movl (%esp), %eax # 4-byte Reload
953 ; X86-NEXT: movw %ax, 12(%ecx)
954 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
955 ; X86-NEXT: movw %ax, 10(%ecx)
956 ; X86-NEXT: movw %si, 8(%ecx)
957 ; X86-NEXT: movw %di, 6(%ecx)
958 ; X86-NEXT: movw %bx, 4(%ecx)
959 ; X86-NEXT: movw %bp, 2(%ecx)
960 ; X86-NEXT: movw %dx, (%ecx)
961 ; X86-NEXT: movl %ecx, %eax
962 ; X86-NEXT: addl $8, %esp
963 ; X86-NEXT: popl %esi
964 ; X86-NEXT: popl %edi
965 ; X86-NEXT: popl %ebx
966 ; X86-NEXT: popl %ebp
968 %r = call <8 x i16> @llvm.umax.v8i16(<8 x i16> %a, <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
972 define <16 x i8> @test_v16i8(<16 x i8> %a, <16 x i8> %b) nounwind {
973 ; SSE-LABEL: test_v16i8:
975 ; SSE-NEXT: pmaxub %xmm1, %xmm0
978 ; AVX-LABEL: test_v16i8:
980 ; AVX-NEXT: vpmaxub %xmm1, %xmm0, %xmm0
983 ; X86-LABEL: test_v16i8:
985 ; X86-NEXT: pushl %ebp
986 ; X86-NEXT: pushl %ebx
987 ; X86-NEXT: pushl %edi
988 ; X86-NEXT: pushl %esi
989 ; X86-NEXT: subl $40, %esp
990 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
991 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
992 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
993 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
994 ; X86-NEXT: cmpb %bl, %al
995 ; X86-NEXT: cmoval %eax, %ebx
996 ; X86-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
997 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
998 ; X86-NEXT: cmpb %dl, %al
999 ; X86-NEXT: cmoval %eax, %edx
1000 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1001 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1002 ; X86-NEXT: cmpb %cl, %al
1003 ; X86-NEXT: cmoval %eax, %ecx
1004 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1005 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1006 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1007 ; X86-NEXT: cmpb %cl, %al
1008 ; X86-NEXT: cmoval %eax, %ecx
1009 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1010 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1011 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1012 ; X86-NEXT: cmpb %cl, %al
1013 ; X86-NEXT: cmoval %eax, %ecx
1014 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1015 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1016 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1017 ; X86-NEXT: cmpb %cl, %al
1018 ; X86-NEXT: cmoval %eax, %ecx
1019 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1020 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1021 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1022 ; X86-NEXT: cmpb %cl, %al
1023 ; X86-NEXT: cmoval %eax, %ecx
1024 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1025 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1026 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1027 ; X86-NEXT: cmpb %cl, %al
1028 ; X86-NEXT: cmoval %eax, %ecx
1029 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1030 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1031 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1032 ; X86-NEXT: cmpb %cl, %al
1033 ; X86-NEXT: cmoval %eax, %ecx
1034 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1035 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1036 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1037 ; X86-NEXT: cmpb %cl, %al
1038 ; X86-NEXT: cmoval %eax, %ecx
1039 ; X86-NEXT: movl %ecx, (%esp) # 4-byte Spill
1040 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1041 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1042 ; X86-NEXT: cmpb %cl, %al
1043 ; X86-NEXT: cmoval %eax, %ecx
1044 ; X86-NEXT: movl %ecx, %ebp
1045 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1046 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1047 ; X86-NEXT: cmpb %cl, %al
1048 ; X86-NEXT: cmoval %eax, %ecx
1049 ; X86-NEXT: movl %ecx, %edi
1050 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1051 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1052 ; X86-NEXT: cmpb %cl, %al
1053 ; X86-NEXT: cmoval %eax, %ecx
1054 ; X86-NEXT: movl %ecx, %esi
1055 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
1056 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1057 ; X86-NEXT: cmpb %bl, %al
1058 ; X86-NEXT: cmoval %eax, %ebx
1059 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
1060 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1061 ; X86-NEXT: cmpb %dl, %al
1062 ; X86-NEXT: cmoval %eax, %edx
1063 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1064 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1065 ; X86-NEXT: cmpb %cl, %al
1066 ; X86-NEXT: cmoval %eax, %ecx
1067 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1068 ; X86-NEXT: movb %cl, 15(%eax)
1069 ; X86-NEXT: movb %dl, 14(%eax)
1070 ; X86-NEXT: movb %bl, 13(%eax)
1071 ; X86-NEXT: movl %esi, %ecx
1072 ; X86-NEXT: movb %cl, 12(%eax)
1073 ; X86-NEXT: movl %edi, %ecx
1074 ; X86-NEXT: movb %cl, 11(%eax)
1075 ; X86-NEXT: movl %ebp, %ecx
1076 ; X86-NEXT: movb %cl, 10(%eax)
1077 ; X86-NEXT: movl (%esp), %ecx # 4-byte Reload
1078 ; X86-NEXT: movb %cl, 9(%eax)
1079 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1080 ; X86-NEXT: movb %cl, 8(%eax)
1081 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1082 ; X86-NEXT: movb %cl, 7(%eax)
1083 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1084 ; X86-NEXT: movb %cl, 6(%eax)
1085 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1086 ; X86-NEXT: movb %cl, 5(%eax)
1087 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1088 ; X86-NEXT: movb %cl, 4(%eax)
1089 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1090 ; X86-NEXT: movb %cl, 3(%eax)
1091 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1092 ; X86-NEXT: movb %cl, 2(%eax)
1093 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1094 ; X86-NEXT: movb %cl, 1(%eax)
1095 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1096 ; X86-NEXT: movb %cl, (%eax)
1097 ; X86-NEXT: addl $40, %esp
1098 ; X86-NEXT: popl %esi
1099 ; X86-NEXT: popl %edi
1100 ; X86-NEXT: popl %ebx
1101 ; X86-NEXT: popl %ebp
1103 %r = call <16 x i8> @llvm.umax.v16i8(<16 x i8> %a, <16 x i8> %b)
1107 define <16 x i8> @test_v16i8_1(<16 x i8> %a) nounwind {
1108 ; SSE-LABEL: test_v16i8_1:
1110 ; SSE-NEXT: pmaxub {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
1113 ; AVX-LABEL: test_v16i8_1:
1115 ; AVX-NEXT: vpmaxub {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1118 ; X86-LABEL: test_v16i8_1:
1120 ; X86-NEXT: pushl %ebp
1121 ; X86-NEXT: pushl %ebx
1122 ; X86-NEXT: pushl %edi
1123 ; X86-NEXT: pushl %esi
1124 ; X86-NEXT: subl $40, %esp
1125 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1126 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1127 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
1128 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
1129 ; X86-NEXT: cmpb $1, %bl
1130 ; X86-NEXT: adcl $0, %ebx
1131 ; X86-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1132 ; X86-NEXT: cmpb $1, %dl
1133 ; X86-NEXT: adcl $0, %edx
1134 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1135 ; X86-NEXT: cmpb $1, %cl
1136 ; X86-NEXT: adcl $0, %ecx
1137 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1138 ; X86-NEXT: cmpb $1, %al
1139 ; X86-NEXT: adcl $0, %eax
1140 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1141 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1142 ; X86-NEXT: cmpb $1, %al
1143 ; X86-NEXT: adcl $0, %eax
1144 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1145 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1146 ; X86-NEXT: cmpb $1, %al
1147 ; X86-NEXT: adcl $0, %eax
1148 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1149 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1150 ; X86-NEXT: cmpb $1, %al
1151 ; X86-NEXT: adcl $0, %eax
1152 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1153 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1154 ; X86-NEXT: cmpb $1, %al
1155 ; X86-NEXT: adcl $0, %eax
1156 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1157 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1158 ; X86-NEXT: cmpb $1, %al
1159 ; X86-NEXT: adcl $0, %eax
1160 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
1161 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1162 ; X86-NEXT: cmpb $1, %al
1163 ; X86-NEXT: adcl $0, %eax
1164 ; X86-NEXT: movl %eax, (%esp) # 4-byte Spill
1165 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1166 ; X86-NEXT: cmpb $1, %al
1167 ; X86-NEXT: adcl $0, %eax
1168 ; X86-NEXT: movl %eax, %ebp
1169 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1170 ; X86-NEXT: cmpb $1, %al
1171 ; X86-NEXT: adcl $0, %eax
1172 ; X86-NEXT: movl %eax, %edi
1173 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1174 ; X86-NEXT: cmpb $1, %al
1175 ; X86-NEXT: adcl $0, %eax
1176 ; X86-NEXT: movl %eax, %esi
1177 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
1178 ; X86-NEXT: cmpb $1, %bl
1179 ; X86-NEXT: adcl $0, %ebx
1180 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
1181 ; X86-NEXT: cmpb $1, %dl
1182 ; X86-NEXT: adcl $0, %edx
1183 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1184 ; X86-NEXT: cmpb $1, %cl
1185 ; X86-NEXT: adcl $0, %ecx
1186 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1187 ; X86-NEXT: movb %cl, 15(%eax)
1188 ; X86-NEXT: movb %dl, 14(%eax)
1189 ; X86-NEXT: movb %bl, 13(%eax)
1190 ; X86-NEXT: movl %esi, %ecx
1191 ; X86-NEXT: movb %cl, 12(%eax)
1192 ; X86-NEXT: movl %edi, %ecx
1193 ; X86-NEXT: movb %cl, 11(%eax)
1194 ; X86-NEXT: movl %ebp, %ecx
1195 ; X86-NEXT: movb %cl, 10(%eax)
1196 ; X86-NEXT: movl (%esp), %ecx # 4-byte Reload
1197 ; X86-NEXT: movb %cl, 9(%eax)
1198 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1199 ; X86-NEXT: movb %cl, 8(%eax)
1200 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1201 ; X86-NEXT: movb %cl, 7(%eax)
1202 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1203 ; X86-NEXT: movb %cl, 6(%eax)
1204 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1205 ; X86-NEXT: movb %cl, 5(%eax)
1206 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1207 ; X86-NEXT: movb %cl, 4(%eax)
1208 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1209 ; X86-NEXT: movb %cl, 3(%eax)
1210 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1211 ; X86-NEXT: movb %cl, 2(%eax)
1212 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1213 ; X86-NEXT: movb %cl, 1(%eax)
1214 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
1215 ; X86-NEXT: movb %cl, (%eax)
1216 ; X86-NEXT: addl $40, %esp
1217 ; X86-NEXT: popl %esi
1218 ; X86-NEXT: popl %edi
1219 ; X86-NEXT: popl %ebx
1220 ; X86-NEXT: popl %ebp
1222 %r = call <16 x i8> @llvm.umax.v16i8(<16 x i8> %a, <16 x i8> <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>)
1226 define i16 @test_signbits_i16(i16 %a, i16 %b) nounwind {
1227 ; X64-LABEL: test_signbits_i16:
1229 ; X64-NEXT: movswl %si, %eax
1230 ; X64-NEXT: movswl %di, %ecx
1231 ; X64-NEXT: shrl $15, %ecx
1232 ; X64-NEXT: shrl $8, %eax
1233 ; X64-NEXT: cmpw %ax, %cx
1234 ; X64-NEXT: cmoval %ecx, %eax
1235 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
1238 ; X86-LABEL: test_signbits_i16:
1240 ; X86-NEXT: movsbl {{[0-9]+}}(%esp), %ecx
1241 ; X86-NEXT: movswl {{[0-9]+}}(%esp), %eax
1242 ; X86-NEXT: shrl $15, %eax
1243 ; X86-NEXT: cmpw %cx, %ax
1244 ; X86-NEXT: cmovbel %ecx, %eax
1245 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
1247 %ax = ashr i16 %a, 15
1248 %bx = ashr i16 %b, 8
1249 %r = call i16 @llvm.umax.i16(i16 %ax, i16 %bx)
1253 define i32 @test_signbits_i32(i32 %a, i32 %b) nounwind {
1254 ; X64-LABEL: test_signbits_i32:
1256 ; X64-NEXT: movl %esi, %eax
1257 ; X64-NEXT: sarl $16, %edi
1258 ; X64-NEXT: sarl $17, %eax
1259 ; X64-NEXT: cmpl %eax, %edi
1260 ; X64-NEXT: cmoval %edi, %eax
1263 ; X86-LABEL: test_signbits_i32:
1265 ; X86-NEXT: movswl {{[0-9]+}}(%esp), %ecx
1266 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1267 ; X86-NEXT: sarl $17, %eax
1268 ; X86-NEXT: cmpl %eax, %ecx
1269 ; X86-NEXT: cmoval %ecx, %eax
1271 %ax = ashr i32 %a, 16
1272 %bx = ashr i32 %b, 17
1273 %r = call i32 @llvm.umax.i32(i32 %ax, i32 %bx)
1277 define i64 @test_signbits_i64(i64 %a, i64 %b) nounwind {
1278 ; X64-LABEL: test_signbits_i64:
1280 ; X64-NEXT: movq %rsi, %rax
1281 ; X64-NEXT: sarq $32, %rdi
1282 ; X64-NEXT: sarq $32, %rax
1283 ; X64-NEXT: cmpq %rax, %rdi
1284 ; X64-NEXT: cmovaq %rdi, %rax
1287 ; X86-LABEL: test_signbits_i64:
1289 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1290 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1291 ; X86-NEXT: cmpl %eax, %ecx
1292 ; X86-NEXT: cmoval %ecx, %eax
1293 ; X86-NEXT: movl %eax, %edx
1294 ; X86-NEXT: sarl $31, %edx
1296 %ax = ashr i64 %a, 32
1297 %bx = ashr i64 %b, 32
1298 %r = call i64 @llvm.umax.i64(i64 %ax, i64 %bx)
1302 define i128 @test_signbits_i128(i128 %a, i128 %b) nounwind {
1303 ; X64-LABEL: test_signbits_i128:
1305 ; X64-NEXT: movq %rcx, %rax
1306 ; X64-NEXT: sarq $28, %rax
1307 ; X64-NEXT: cmpq %rax, %rsi
1308 ; X64-NEXT: cmovaq %rsi, %rax
1309 ; X64-NEXT: movq %rax, %rdx
1310 ; X64-NEXT: sarq $63, %rdx
1313 ; X86-LABEL: test_signbits_i128:
1315 ; X86-NEXT: pushl %ebx
1316 ; X86-NEXT: pushl %edi
1317 ; X86-NEXT: pushl %esi
1318 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1319 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1320 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
1321 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1322 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
1323 ; X86-NEXT: shrdl $28, %edi, %ecx
1324 ; X86-NEXT: sarl $28, %edi
1325 ; X86-NEXT: cmpl %esi, %ecx
1326 ; X86-NEXT: movl %edi, %ebx
1327 ; X86-NEXT: sbbl %edx, %ebx
1328 ; X86-NEXT: cmovbl %esi, %ecx
1329 ; X86-NEXT: cmovbl %edx, %edi
1330 ; X86-NEXT: movl %edi, 4(%eax)
1331 ; X86-NEXT: sarl $31, %edi
1332 ; X86-NEXT: movl %ecx, (%eax)
1333 ; X86-NEXT: movl %edi, 12(%eax)
1334 ; X86-NEXT: movl %edi, 8(%eax)
1335 ; X86-NEXT: popl %esi
1336 ; X86-NEXT: popl %edi
1337 ; X86-NEXT: popl %ebx
1339 %ax = ashr i128 %a, 64
1340 %bx = ashr i128 %b, 92
1341 %r = call i128 @llvm.umax.i128(i128 %ax, i128 %bx)