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 i32 @llvm.sadd.sat.i32 (i32, i32)
7 declare i64 @llvm.sadd.sat.i64 (i64, i64)
8 declare <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32>, <4 x i32>)
10 define i32 @func(i32 %x, i32 %y) nounwind {
13 ; X86-NEXT: pushl %esi
14 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
15 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
16 ; X86-NEXT: xorl %ecx, %ecx
17 ; X86-NEXT: movl %eax, %esi
18 ; X86-NEXT: addl %edx, %esi
20 ; X86-NEXT: addl $2147483647, %ecx # imm = 0x7FFFFFFF
21 ; X86-NEXT: addl %edx, %eax
22 ; X86-NEXT: cmovol %ecx, %eax
28 ; X64-NEXT: xorl %eax, %eax
29 ; X64-NEXT: movl %edi, %ecx
30 ; X64-NEXT: addl %esi, %ecx
32 ; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
33 ; X64-NEXT: addl %esi, %edi
34 ; X64-NEXT: cmovnol %edi, %eax
36 %tmp = call i32 @llvm.sadd.sat.i32(i32 %x, i32 %y);
40 define i64 @func2(i64 %x, i64 %y) nounwind {
43 ; X86-NEXT: pushl %ebp
44 ; X86-NEXT: pushl %ebx
45 ; X86-NEXT: pushl %edi
46 ; X86-NEXT: pushl %esi
47 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
48 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
49 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
50 ; X86-NEXT: addl {{[0-9]+}}(%esp), %edi
51 ; X86-NEXT: movl %ebx, %ebp
52 ; X86-NEXT: adcl %esi, %ebp
53 ; X86-NEXT: movl %ebp, %eax
54 ; X86-NEXT: sarl $31, %eax
55 ; X86-NEXT: xorl %ecx, %ecx
56 ; X86-NEXT: testl %ebp, %ebp
58 ; X86-NEXT: movl %ecx, %edx
59 ; X86-NEXT: addl $2147483647, %edx # imm = 0x7FFFFFFF
60 ; X86-NEXT: testl %ebx, %ebx
62 ; X86-NEXT: cmpb %cl, %bl
64 ; X86-NEXT: testl %esi, %esi
66 ; X86-NEXT: cmpb %ch, %bl
68 ; X86-NEXT: testb %cl, %ch
69 ; X86-NEXT: cmovel %ebp, %edx
70 ; X86-NEXT: cmovel %edi, %eax
79 ; X64-NEXT: xorl %ecx, %ecx
80 ; X64-NEXT: movq %rdi, %rax
81 ; X64-NEXT: addq %rsi, %rax
83 ; X64-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
84 ; X64-NEXT: addq %rcx, %rax
85 ; X64-NEXT: addq %rsi, %rdi
86 ; X64-NEXT: cmovnoq %rdi, %rax
88 %tmp = call i64 @llvm.sadd.sat.i64(i64 %x, i64 %y);
92 define i4 @func3(i4 %x, i4 %y) nounwind {
95 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
96 ; X86-NEXT: movb {{[0-9]+}}(%esp), %dl
97 ; X86-NEXT: shlb $4, %dl
98 ; X86-NEXT: shlb $4, %al
99 ; X86-NEXT: movl %eax, %ecx
100 ; X86-NEXT: addb %dl, %cl
101 ; X86-NEXT: setns %cl
102 ; X86-NEXT: addb %dl, %al
103 ; X86-NEXT: jno .LBB2_2
105 ; X86-NEXT: addb $127, %cl
106 ; X86-NEXT: movl %ecx, %eax
108 ; X86-NEXT: sarb $4, %al
113 ; X64-NEXT: movl %edi, %eax
114 ; X64-NEXT: shlb $4, %sil
115 ; X64-NEXT: shlb $4, %al
116 ; X64-NEXT: movl %eax, %ecx
117 ; X64-NEXT: addb %sil, %cl
118 ; X64-NEXT: setns %cl
119 ; X64-NEXT: addb %sil, %al
120 ; X64-NEXT: jno .LBB2_2
122 ; X64-NEXT: addb $127, %cl
123 ; X64-NEXT: movl %ecx, %eax
125 ; X64-NEXT: sarb $4, %al
126 ; X64-NEXT: # kill: def $al killed $al killed $eax
128 %tmp = call i4 @llvm.sadd.sat.i4(i4 %x, i4 %y);
132 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
135 ; X86-NEXT: pushl %ebp
136 ; X86-NEXT: pushl %ebx
137 ; X86-NEXT: pushl %edi
138 ; X86-NEXT: pushl %esi
139 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
140 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
141 ; X86-NEXT: xorl %eax, %eax
142 ; X86-NEXT: movl %ecx, %esi
143 ; X86-NEXT: addl %edx, %esi
144 ; X86-NEXT: setns %al
145 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
146 ; X86-NEXT: addl %edx, %ecx
147 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
148 ; X86-NEXT: cmovol %eax, %ecx
149 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
150 ; X86-NEXT: xorl %eax, %eax
151 ; X86-NEXT: movl %edx, %edi
152 ; X86-NEXT: addl %esi, %edi
153 ; X86-NEXT: setns %al
154 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
155 ; X86-NEXT: addl %esi, %edx
156 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
157 ; X86-NEXT: cmovol %eax, %edx
158 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
159 ; X86-NEXT: xorl %eax, %eax
160 ; X86-NEXT: movl %esi, %ebx
161 ; X86-NEXT: addl %edi, %ebx
162 ; X86-NEXT: setns %al
163 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
164 ; X86-NEXT: addl %edi, %esi
165 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
166 ; X86-NEXT: cmovol %eax, %esi
167 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
168 ; X86-NEXT: xorl %ebx, %ebx
169 ; X86-NEXT: movl %edi, %ebp
170 ; X86-NEXT: addl %eax, %ebp
171 ; X86-NEXT: setns %bl
172 ; X86-NEXT: addl $2147483647, %ebx # imm = 0x7FFFFFFF
173 ; X86-NEXT: addl %eax, %edi
174 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
175 ; X86-NEXT: cmovol %ebx, %edi
176 ; X86-NEXT: movl %ecx, 12(%eax)
177 ; X86-NEXT: movl %edx, 8(%eax)
178 ; X86-NEXT: movl %esi, 4(%eax)
179 ; X86-NEXT: movl %edi, (%eax)
180 ; X86-NEXT: popl %esi
181 ; X86-NEXT: popl %edi
182 ; X86-NEXT: popl %ebx
183 ; X86-NEXT: popl %ebp
188 ; X64-NEXT: pxor %xmm3, %xmm3
189 ; X64-NEXT: pxor %xmm4, %xmm4
190 ; X64-NEXT: pcmpgtd %xmm1, %xmm4
191 ; X64-NEXT: pcmpeqd %xmm2, %xmm2
192 ; X64-NEXT: pxor %xmm2, %xmm4
193 ; X64-NEXT: pxor %xmm5, %xmm5
194 ; X64-NEXT: pcmpgtd %xmm0, %xmm5
195 ; X64-NEXT: pxor %xmm2, %xmm5
196 ; X64-NEXT: pcmpeqd %xmm5, %xmm4
197 ; X64-NEXT: paddd %xmm1, %xmm0
198 ; X64-NEXT: pcmpgtd %xmm0, %xmm3
199 ; X64-NEXT: pxor %xmm3, %xmm2
200 ; X64-NEXT: pcmpeqd %xmm5, %xmm2
201 ; X64-NEXT: pandn %xmm4, %xmm2
202 ; X64-NEXT: movdqa %xmm3, %xmm1
203 ; X64-NEXT: pandn {{.*}}(%rip), %xmm1
204 ; X64-NEXT: psrld $1, %xmm3
205 ; X64-NEXT: por %xmm1, %xmm3
206 ; X64-NEXT: pand %xmm2, %xmm3
207 ; X64-NEXT: pandn %xmm0, %xmm2
208 ; X64-NEXT: por %xmm3, %xmm2
209 ; X64-NEXT: movdqa %xmm2, %xmm0
211 %tmp = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %x, <4 x i32> %y);