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.sadd.sat.i4(i4, i4)
6 declare i8 @llvm.sadd.sat.i8(i8, i8)
7 declare i16 @llvm.sadd.sat.i16(i16, i16)
8 declare i32 @llvm.sadd.sat.i32(i32, i32)
9 declare i64 @llvm.sadd.sat.i64(i64, i64)
10 declare <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32>, <4 x i32>)
12 define i32 @func(i32 %x, i32 %y) nounwind {
15 ; X86-NEXT: pushl %esi
16 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
17 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
18 ; X86-NEXT: xorl %ecx, %ecx
19 ; X86-NEXT: movl %eax, %esi
20 ; X86-NEXT: addl %edx, %esi
22 ; X86-NEXT: addl $2147483647, %ecx # imm = 0x7FFFFFFF
23 ; X86-NEXT: addl %edx, %eax
24 ; X86-NEXT: cmovol %ecx, %eax
30 ; X64-NEXT: xorl %eax, %eax
31 ; X64-NEXT: movl %edi, %ecx
32 ; X64-NEXT: addl %esi, %ecx
34 ; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
35 ; X64-NEXT: addl %esi, %edi
36 ; X64-NEXT: cmovnol %edi, %eax
38 %tmp = call i32 @llvm.sadd.sat.i32(i32 %x, i32 %y);
42 define i64 @func2(i64 %x, i64 %y) nounwind {
45 ; X86-NEXT: pushl %ebp
46 ; X86-NEXT: pushl %ebx
47 ; X86-NEXT: pushl %edi
48 ; X86-NEXT: pushl %esi
49 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
50 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
51 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
52 ; X86-NEXT: addl {{[0-9]+}}(%esp), %edi
53 ; X86-NEXT: movl %ebx, %ebp
54 ; X86-NEXT: adcl %esi, %ebp
55 ; X86-NEXT: movl %ebp, %eax
56 ; X86-NEXT: sarl $31, %eax
57 ; X86-NEXT: xorl %ecx, %ecx
58 ; X86-NEXT: testl %ebp, %ebp
60 ; X86-NEXT: movl %ecx, %edx
61 ; X86-NEXT: addl $2147483647, %edx # imm = 0x7FFFFFFF
62 ; X86-NEXT: testl %ebx, %ebx
64 ; X86-NEXT: cmpb %cl, %bl
66 ; X86-NEXT: testl %esi, %esi
68 ; X86-NEXT: cmpb %ch, %bl
70 ; X86-NEXT: testb %cl, %ch
71 ; X86-NEXT: cmovel %ebp, %edx
72 ; X86-NEXT: cmovel %edi, %eax
81 ; X64-NEXT: xorl %ecx, %ecx
82 ; X64-NEXT: movq %rdi, %rax
83 ; X64-NEXT: addq %rsi, %rax
85 ; X64-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
86 ; X64-NEXT: addq %rcx, %rax
87 ; X64-NEXT: addq %rsi, %rdi
88 ; X64-NEXT: cmovnoq %rdi, %rax
90 %tmp = call i64 @llvm.sadd.sat.i64(i64 %x, i64 %y);
94 define signext i16 @func16(i16 signext %x, i16 signext %y) nounwind {
97 ; X86-NEXT: pushl %esi
98 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
99 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %edx
100 ; X86-NEXT: xorl %ecx, %ecx
101 ; X86-NEXT: movl %eax, %esi
102 ; X86-NEXT: addw %dx, %si
103 ; X86-NEXT: setns %cl
104 ; X86-NEXT: addl $32767, %ecx # imm = 0x7FFF
105 ; X86-NEXT: addw %dx, %ax
106 ; X86-NEXT: cmovol %ecx, %eax
107 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
108 ; X86-NEXT: popl %esi
113 ; X64-NEXT: xorl %eax, %eax
114 ; X64-NEXT: movl %edi, %ecx
115 ; X64-NEXT: addw %si, %cx
116 ; X64-NEXT: setns %al
117 ; X64-NEXT: addl $32767, %eax # imm = 0x7FFF
118 ; X64-NEXT: addw %si, %di
119 ; X64-NEXT: cmovnol %edi, %eax
120 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
122 %tmp = call i16 @llvm.sadd.sat.i16(i16 %x, i16 %y)
126 define signext i8 @func8(i8 signext %x, i8 signext %y) nounwind {
129 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
130 ; X86-NEXT: movb {{[0-9]+}}(%esp), %dl
131 ; X86-NEXT: xorl %ecx, %ecx
132 ; X86-NEXT: movb %al, %ah
133 ; X86-NEXT: addb %dl, %ah
134 ; X86-NEXT: setns %cl
135 ; X86-NEXT: addl $127, %ecx
136 ; X86-NEXT: addb %dl, %al
137 ; X86-NEXT: movzbl %al, %eax
138 ; X86-NEXT: cmovol %ecx, %eax
139 ; X86-NEXT: # kill: def $al killed $al killed $eax
144 ; X64-NEXT: xorl %ecx, %ecx
145 ; X64-NEXT: movl %edi, %eax
146 ; X64-NEXT: addb %sil, %al
147 ; X64-NEXT: setns %cl
148 ; X64-NEXT: addl $127, %ecx
149 ; X64-NEXT: addb %sil, %dil
150 ; X64-NEXT: movzbl %dil, %eax
151 ; X64-NEXT: cmovol %ecx, %eax
152 ; X64-NEXT: # kill: def $al killed $al killed $eax
154 %tmp = call i8 @llvm.sadd.sat.i8(i8 %x, i8 %y)
158 define signext i4 @func3(i4 signext %x, i4 signext %y) nounwind {
161 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
162 ; X86-NEXT: addb {{[0-9]+}}(%esp), %al
163 ; X86-NEXT: movzbl %al, %ecx
164 ; X86-NEXT: cmpb $7, %al
165 ; X86-NEXT: movl $7, %eax
166 ; X86-NEXT: cmovll %ecx, %eax
167 ; X86-NEXT: cmpb $-8, %al
168 ; X86-NEXT: movl $248, %ecx
169 ; X86-NEXT: cmovgl %eax, %ecx
170 ; X86-NEXT: movsbl %cl, %eax
175 ; X64-NEXT: addb %sil, %dil
176 ; X64-NEXT: movzbl %dil, %eax
177 ; X64-NEXT: cmpb $7, %al
178 ; X64-NEXT: movl $7, %ecx
179 ; X64-NEXT: cmovll %eax, %ecx
180 ; X64-NEXT: cmpb $-8, %cl
181 ; X64-NEXT: movl $248, %eax
182 ; X64-NEXT: cmovgl %ecx, %eax
183 ; X64-NEXT: movsbl %al, %eax
185 %tmp = call i4 @llvm.sadd.sat.i4(i4 %x, i4 %y);
189 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
192 ; X86-NEXT: pushl %ebp
193 ; X86-NEXT: pushl %ebx
194 ; X86-NEXT: pushl %edi
195 ; X86-NEXT: pushl %esi
196 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
197 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
198 ; X86-NEXT: xorl %eax, %eax
199 ; X86-NEXT: movl %ecx, %esi
200 ; X86-NEXT: addl %edx, %esi
201 ; X86-NEXT: setns %al
202 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
203 ; X86-NEXT: addl %edx, %ecx
204 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
205 ; X86-NEXT: cmovol %eax, %ecx
206 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
207 ; X86-NEXT: xorl %eax, %eax
208 ; X86-NEXT: movl %edx, %edi
209 ; X86-NEXT: addl %esi, %edi
210 ; X86-NEXT: setns %al
211 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
212 ; X86-NEXT: addl %esi, %edx
213 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
214 ; X86-NEXT: cmovol %eax, %edx
215 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
216 ; X86-NEXT: xorl %eax, %eax
217 ; X86-NEXT: movl %esi, %ebx
218 ; X86-NEXT: addl %edi, %ebx
219 ; X86-NEXT: setns %al
220 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
221 ; X86-NEXT: addl %edi, %esi
222 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
223 ; X86-NEXT: cmovol %eax, %esi
224 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
225 ; X86-NEXT: xorl %ebx, %ebx
226 ; X86-NEXT: movl %edi, %ebp
227 ; X86-NEXT: addl %eax, %ebp
228 ; X86-NEXT: setns %bl
229 ; X86-NEXT: addl $2147483647, %ebx # imm = 0x7FFFFFFF
230 ; X86-NEXT: addl %eax, %edi
231 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
232 ; X86-NEXT: cmovol %ebx, %edi
233 ; X86-NEXT: movl %ecx, 12(%eax)
234 ; X86-NEXT: movl %edx, 8(%eax)
235 ; X86-NEXT: movl %esi, 4(%eax)
236 ; X86-NEXT: movl %edi, (%eax)
237 ; X86-NEXT: popl %esi
238 ; X86-NEXT: popl %edi
239 ; X86-NEXT: popl %ebx
240 ; X86-NEXT: popl %ebp
245 ; X64-NEXT: pxor %xmm2, %xmm2
246 ; X64-NEXT: pxor %xmm3, %xmm3
247 ; X64-NEXT: pcmpgtd %xmm1, %xmm3
248 ; X64-NEXT: paddd %xmm0, %xmm1
249 ; X64-NEXT: pcmpgtd %xmm1, %xmm0
250 ; X64-NEXT: pxor %xmm3, %xmm0
251 ; X64-NEXT: pcmpgtd %xmm1, %xmm2
252 ; X64-NEXT: movdqa %xmm2, %xmm3
253 ; X64-NEXT: pandn {{.*}}(%rip), %xmm3
254 ; X64-NEXT: psrld $1, %xmm2
255 ; X64-NEXT: por %xmm3, %xmm2
256 ; X64-NEXT: pand %xmm0, %xmm2
257 ; X64-NEXT: pandn %xmm1, %xmm0
258 ; X64-NEXT: por %xmm2, %xmm0
260 %tmp = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %x, <4 x i32> %y);