1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686 -mattr=cmov | FileCheck %s --check-prefixes=CHECK,X86
3 ; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefixes=CHECK,X64
5 declare i4 @llvm.usub.sat.i4 (i4, i4)
6 declare i32 @llvm.usub.sat.i32 (i32, i32)
7 declare i64 @llvm.usub.sat.i64 (i64, i64)
8 declare <4 x i32> @llvm.usub.sat.v4i32(<4 x i32>, <4 x i32>)
10 define i32 @func(i32 %x, i32 %y) nounwind {
13 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
14 ; X86-NEXT: xorl %ecx, %ecx
15 ; X86-NEXT: subl {{[0-9]+}}(%esp), %eax
16 ; X86-NEXT: cmovbl %ecx, %eax
21 ; X64-NEXT: xorl %eax, %eax
22 ; X64-NEXT: subl %esi, %edi
23 ; X64-NEXT: cmovael %edi, %eax
25 %tmp = call i32 @llvm.usub.sat.i32(i32 %x, i32 %y)
29 define i64 @func2(i64 %x, i64 %y) nounwind {
32 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
33 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
34 ; X86-NEXT: xorl %ecx, %ecx
35 ; X86-NEXT: subl {{[0-9]+}}(%esp), %eax
36 ; X86-NEXT: sbbl {{[0-9]+}}(%esp), %edx
37 ; X86-NEXT: cmovbl %ecx, %edx
38 ; X86-NEXT: cmovbl %ecx, %eax
43 ; X64-NEXT: xorl %eax, %eax
44 ; X64-NEXT: subq %rsi, %rdi
45 ; X64-NEXT: cmovaeq %rdi, %rax
47 %tmp = call i64 @llvm.usub.sat.i64(i64 %x, i64 %y)
51 define i4 @func3(i4 %x, i4 %y) nounwind {
54 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
55 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
56 ; X86-NEXT: shlb $4, %cl
57 ; X86-NEXT: shlb $4, %al
58 ; X86-NEXT: xorl %edx, %edx
59 ; X86-NEXT: subb %cl, %al
60 ; X86-NEXT: movzbl %al, %eax
61 ; X86-NEXT: cmovbl %edx, %eax
62 ; X86-NEXT: shrb $4, %al
63 ; X86-NEXT: # kill: def $al killed $al killed $eax
68 ; X64-NEXT: shlb $4, %sil
69 ; X64-NEXT: shlb $4, %dil
70 ; X64-NEXT: xorl %ecx, %ecx
71 ; X64-NEXT: subb %sil, %dil
72 ; X64-NEXT: movzbl %dil, %eax
73 ; X64-NEXT: cmovbl %ecx, %eax
74 ; X64-NEXT: shrb $4, %al
75 ; X64-NEXT: # kill: def $al killed $al killed $eax
77 %tmp = call i4 @llvm.usub.sat.i4(i4 %x, i4 %y)
81 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
84 ; X86-NEXT: pushl %ebx
85 ; X86-NEXT: pushl %edi
86 ; X86-NEXT: pushl %esi
87 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
88 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
89 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
90 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
91 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
92 ; X86-NEXT: xorl %ebx, %ebx
93 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edi
94 ; X86-NEXT: cmovbl %ebx, %edi
95 ; X86-NEXT: subl {{[0-9]+}}(%esp), %esi
96 ; X86-NEXT: cmovbl %ebx, %esi
97 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edx
98 ; X86-NEXT: cmovbl %ebx, %edx
99 ; X86-NEXT: subl {{[0-9]+}}(%esp), %ecx
100 ; X86-NEXT: cmovbl %ebx, %ecx
101 ; X86-NEXT: movl %ecx, 12(%eax)
102 ; X86-NEXT: movl %edx, 8(%eax)
103 ; X86-NEXT: movl %esi, 4(%eax)
104 ; X86-NEXT: movl %edi, (%eax)
105 ; X86-NEXT: popl %esi
106 ; X86-NEXT: popl %edi
107 ; X86-NEXT: popl %ebx
112 ; X64-NEXT: movdqa {{.*#+}} xmm2 = [2147483648,2147483648,2147483648,2147483648]
113 ; X64-NEXT: movdqa %xmm1, %xmm3
114 ; X64-NEXT: pxor %xmm2, %xmm3
115 ; X64-NEXT: pxor %xmm0, %xmm2
116 ; X64-NEXT: pcmpgtd %xmm3, %xmm2
117 ; X64-NEXT: psubd %xmm1, %xmm0
118 ; X64-NEXT: pand %xmm2, %xmm0
120 %tmp = call <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %x, <4 x i32> %y)