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.ssub.sat.i4(i4, i4)
6 declare i8 @llvm.ssub.sat.i8(i8, i8)
7 declare i16 @llvm.ssub.sat.i16(i16, i16)
8 declare i32 @llvm.ssub.sat.i32(i32, i32)
9 declare i64 @llvm.ssub.sat.i64(i64, i64)
10 declare <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32>, <4 x i32>)
12 define i32 @func(i32 %x, i32 %y) nounwind {
15 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
16 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
17 ; X86-NEXT: xorl %ecx, %ecx
18 ; X86-NEXT: cmpl %edx, %eax
20 ; X86-NEXT: addl $2147483647, %ecx # imm = 0x7FFFFFFF
21 ; X86-NEXT: subl %edx, %eax
22 ; X86-NEXT: cmovol %ecx, %eax
27 ; X64-NEXT: xorl %eax, %eax
28 ; X64-NEXT: cmpl %esi, %edi
30 ; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
31 ; X64-NEXT: subl %esi, %edi
32 ; X64-NEXT: cmovnol %edi, %eax
34 %tmp = call i32 @llvm.ssub.sat.i32(i32 %x, i32 %y)
38 define i64 @func2(i64 %x, i64 %y) nounwind {
41 ; X86-NEXT: pushl %ebp
42 ; X86-NEXT: pushl %ebx
43 ; X86-NEXT: pushl %edi
44 ; X86-NEXT: pushl %esi
45 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
46 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
47 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
48 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edi
49 ; X86-NEXT: movl %ebx, %ebp
50 ; X86-NEXT: sbbl %esi, %ebp
51 ; X86-NEXT: movl %ebp, %eax
52 ; X86-NEXT: sarl $31, %eax
53 ; X86-NEXT: xorl %ecx, %ecx
54 ; X86-NEXT: testl %ebp, %ebp
56 ; X86-NEXT: movl %ecx, %edx
57 ; X86-NEXT: addl $2147483647, %edx # imm = 0x7FFFFFFF
58 ; X86-NEXT: testl %ebx, %ebx
60 ; X86-NEXT: cmpb %cl, %bl
62 ; X86-NEXT: testl %esi, %esi
64 ; X86-NEXT: cmpb %ch, %bl
66 ; X86-NEXT: testb %cl, %ch
67 ; X86-NEXT: cmovel %ebp, %edx
68 ; X86-NEXT: cmovel %edi, %eax
77 ; X64-NEXT: xorl %ecx, %ecx
78 ; X64-NEXT: cmpq %rsi, %rdi
80 ; X64-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
81 ; X64-NEXT: addq %rcx, %rax
82 ; X64-NEXT: subq %rsi, %rdi
83 ; X64-NEXT: cmovnoq %rdi, %rax
85 %tmp = call i64 @llvm.ssub.sat.i64(i64 %x, i64 %y)
89 define i16 @func16(i16 %x, i16 %y) nounwind {
92 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
93 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %edx
94 ; X86-NEXT: xorl %ecx, %ecx
95 ; X86-NEXT: cmpw %dx, %ax
97 ; X86-NEXT: addl $32767, %ecx # imm = 0x7FFF
98 ; X86-NEXT: subw %dx, %ax
99 ; X86-NEXT: cmovol %ecx, %eax
100 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
105 ; X64-NEXT: xorl %eax, %eax
106 ; X64-NEXT: cmpw %si, %di
107 ; X64-NEXT: setns %al
108 ; X64-NEXT: addl $32767, %eax # imm = 0x7FFF
109 ; X64-NEXT: subw %si, %di
110 ; X64-NEXT: cmovnol %edi, %eax
111 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
113 %tmp = call i16 @llvm.ssub.sat.i16(i16 %x, i16 %y)
117 define i8 @func8(i8 %x, i8 %y) nounwind {
120 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
121 ; X86-NEXT: movb {{[0-9]+}}(%esp), %dl
122 ; X86-NEXT: xorl %ecx, %ecx
123 ; X86-NEXT: cmpb %dl, %al
124 ; X86-NEXT: setns %cl
125 ; X86-NEXT: addl $127, %ecx
126 ; X86-NEXT: subb %dl, %al
127 ; X86-NEXT: movzbl %al, %eax
128 ; X86-NEXT: cmovol %ecx, %eax
129 ; X86-NEXT: # kill: def $al killed $al killed $eax
134 ; X64-NEXT: xorl %ecx, %ecx
135 ; X64-NEXT: cmpb %sil, %dil
136 ; X64-NEXT: setns %cl
137 ; X64-NEXT: addl $127, %ecx
138 ; X64-NEXT: subb %sil, %dil
139 ; X64-NEXT: movzbl %dil, %eax
140 ; X64-NEXT: cmovol %ecx, %eax
141 ; X64-NEXT: # kill: def $al killed $al killed $eax
143 %tmp = call i8 @llvm.ssub.sat.i8(i8 %x, i8 %y)
147 define i4 @func3(i4 %x, i4 %y) nounwind {
150 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
151 ; X86-NEXT: movb {{[0-9]+}}(%esp), %dl
152 ; X86-NEXT: shlb $4, %dl
153 ; X86-NEXT: shlb $4, %al
154 ; X86-NEXT: xorl %ecx, %ecx
155 ; X86-NEXT: cmpb %dl, %al
156 ; X86-NEXT: setns %cl
157 ; X86-NEXT: addl $127, %ecx
158 ; X86-NEXT: subb %dl, %al
159 ; X86-NEXT: movzbl %al, %eax
160 ; X86-NEXT: cmovol %ecx, %eax
161 ; X86-NEXT: sarb $4, %al
162 ; X86-NEXT: # kill: def $al killed $al killed $eax
167 ; X64-NEXT: shlb $4, %sil
168 ; X64-NEXT: shlb $4, %dil
169 ; X64-NEXT: xorl %ecx, %ecx
170 ; X64-NEXT: cmpb %sil, %dil
171 ; X64-NEXT: setns %cl
172 ; X64-NEXT: addl $127, %ecx
173 ; X64-NEXT: subb %sil, %dil
174 ; X64-NEXT: movzbl %dil, %eax
175 ; X64-NEXT: cmovol %ecx, %eax
176 ; X64-NEXT: sarb $4, %al
177 ; X64-NEXT: # kill: def $al killed $al killed $eax
179 %tmp = call i4 @llvm.ssub.sat.i4(i4 %x, i4 %y)
183 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
186 ; X86-NEXT: pushl %ebx
187 ; X86-NEXT: pushl %edi
188 ; X86-NEXT: pushl %esi
189 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
190 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
191 ; X86-NEXT: xorl %eax, %eax
192 ; X86-NEXT: cmpl %edx, %ecx
193 ; X86-NEXT: setns %al
194 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
195 ; X86-NEXT: subl %edx, %ecx
196 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
197 ; X86-NEXT: cmovol %eax, %ecx
198 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
199 ; X86-NEXT: xorl %eax, %eax
200 ; X86-NEXT: cmpl %esi, %edx
201 ; X86-NEXT: setns %al
202 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
203 ; X86-NEXT: subl %esi, %edx
204 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
205 ; X86-NEXT: cmovol %eax, %edx
206 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
207 ; X86-NEXT: xorl %eax, %eax
208 ; X86-NEXT: cmpl %edi, %esi
209 ; X86-NEXT: setns %al
210 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
211 ; X86-NEXT: subl %edi, %esi
212 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
213 ; X86-NEXT: cmovol %eax, %esi
214 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
215 ; X86-NEXT: xorl %ebx, %ebx
216 ; X86-NEXT: cmpl %eax, %edi
217 ; X86-NEXT: setns %bl
218 ; X86-NEXT: addl $2147483647, %ebx # imm = 0x7FFFFFFF
219 ; X86-NEXT: subl %eax, %edi
220 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
221 ; X86-NEXT: cmovol %ebx, %edi
222 ; X86-NEXT: movl %ecx, 12(%eax)
223 ; X86-NEXT: movl %edx, 8(%eax)
224 ; X86-NEXT: movl %esi, 4(%eax)
225 ; X86-NEXT: movl %edi, (%eax)
226 ; X86-NEXT: popl %esi
227 ; X86-NEXT: popl %edi
228 ; X86-NEXT: popl %ebx
233 ; X64-NEXT: pxor %xmm2, %xmm2
234 ; X64-NEXT: movdqa %xmm0, %xmm3
235 ; X64-NEXT: psubd %xmm1, %xmm3
236 ; X64-NEXT: pcmpgtd %xmm2, %xmm1
237 ; X64-NEXT: pcmpgtd %xmm3, %xmm0
238 ; X64-NEXT: pxor %xmm1, %xmm0
239 ; X64-NEXT: pcmpgtd %xmm3, %xmm2
240 ; X64-NEXT: movdqa %xmm2, %xmm1
241 ; X64-NEXT: pandn {{.*}}(%rip), %xmm1
242 ; X64-NEXT: psrld $1, %xmm2
243 ; X64-NEXT: por %xmm1, %xmm2
244 ; X64-NEXT: pand %xmm0, %xmm2
245 ; X64-NEXT: pandn %xmm3, %xmm0
246 ; X64-NEXT: por %xmm2, %xmm0
248 %tmp = call <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %x, <4 x i32> %y)