1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686 -mattr=cmov | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefix=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: movl {{[0-9]+}}(%esp), %eax
16 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
17 ; X86-NEXT: leal (%eax,%ecx), %edx
18 ; X86-NEXT: sarl $31, %edx
19 ; X86-NEXT: addl $-2147483648, %edx # imm = 0x80000000
20 ; X86-NEXT: addl %ecx, %eax
21 ; X86-NEXT: cmovol %edx, %eax
26 ; X64-NEXT: # kill: def $esi killed $esi def $rsi
27 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
28 ; X64-NEXT: leal (%rdi,%rsi), %eax
29 ; X64-NEXT: sarl $31, %eax
30 ; X64-NEXT: addl $-2147483648, %eax # imm = 0x80000000
31 ; X64-NEXT: addl %esi, %edi
32 ; X64-NEXT: cmovnol %edi, %eax
34 %tmp = call i32 @llvm.sadd.sat.i32(i32 %x, i32 %y);
38 define i64 @func2(i64 %x, i64 %y) nounwind {
41 ; X86-NEXT: pushl %ebx
42 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
43 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
44 ; X86-NEXT: addl {{[0-9]+}}(%esp), %eax
45 ; X86-NEXT: adcl {{[0-9]+}}(%esp), %ecx
47 ; X86-NEXT: movl %ecx, %edx
48 ; X86-NEXT: sarl $31, %edx
49 ; X86-NEXT: testb %bl, %bl
50 ; X86-NEXT: cmovnel %edx, %eax
51 ; X86-NEXT: addl $-2147483648, %edx # imm = 0x80000000
52 ; X86-NEXT: testb %bl, %bl
53 ; X86-NEXT: cmovel %ecx, %edx
59 ; X64-NEXT: leaq (%rdi,%rsi), %rcx
60 ; X64-NEXT: sarq $63, %rcx
61 ; X64-NEXT: movabsq $-9223372036854775808, %rax # imm = 0x8000000000000000
62 ; X64-NEXT: xorq %rcx, %rax
63 ; X64-NEXT: addq %rsi, %rdi
64 ; X64-NEXT: cmovnoq %rdi, %rax
66 %tmp = call i64 @llvm.sadd.sat.i64(i64 %x, i64 %y);
70 define signext i16 @func16(i16 signext %x, i16 signext %y) nounwind {
73 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
74 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
75 ; X86-NEXT: movl %eax, %edx
76 ; X86-NEXT: addw %cx, %dx
77 ; X86-NEXT: movswl %dx, %edx
78 ; X86-NEXT: sarl $15, %edx
79 ; X86-NEXT: xorl $-32768, %edx # imm = 0x8000
80 ; X86-NEXT: addw %cx, %ax
81 ; X86-NEXT: cmovol %edx, %eax
82 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
87 ; X64-NEXT: # kill: def $esi killed $esi def $rsi
88 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
89 ; X64-NEXT: leal (%rdi,%rsi), %eax
91 ; X64-NEXT: sarl $15, %eax
92 ; X64-NEXT: xorl $-32768, %eax # imm = 0x8000
93 ; X64-NEXT: addw %si, %di
94 ; X64-NEXT: cmovnol %edi, %eax
95 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
97 %tmp = call i16 @llvm.sadd.sat.i16(i16 %x, i16 %y)
101 define signext i8 @func8(i8 signext %x, i8 signext %y) nounwind {
104 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
105 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
106 ; X86-NEXT: movl %eax, %edx
107 ; X86-NEXT: addb %cl, %dl
108 ; X86-NEXT: sarb $7, %dl
109 ; X86-NEXT: addb $-128, %dl
110 ; X86-NEXT: addb %cl, %al
111 ; X86-NEXT: movzbl %al, %ecx
112 ; X86-NEXT: movzbl %dl, %eax
113 ; X86-NEXT: cmovnol %ecx, %eax
114 ; X86-NEXT: # kill: def $al killed $al killed $eax
119 ; X64-NEXT: # kill: def $esi killed $esi def $rsi
120 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
121 ; X64-NEXT: leal (%rdi,%rsi), %eax
122 ; X64-NEXT: sarb $7, %al
123 ; X64-NEXT: addb $-128, %al
124 ; X64-NEXT: addb %sil, %dil
125 ; X64-NEXT: movzbl %dil, %ecx
126 ; X64-NEXT: movzbl %al, %eax
127 ; X64-NEXT: cmovnol %ecx, %eax
128 ; X64-NEXT: # kill: def $al killed $al killed $eax
130 %tmp = call i8 @llvm.sadd.sat.i8(i8 %x, i8 %y)
134 define signext i4 @func3(i4 signext %x, i4 signext %y) nounwind {
137 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
138 ; X86-NEXT: addb {{[0-9]+}}(%esp), %al
139 ; X86-NEXT: movzbl %al, %ecx
140 ; X86-NEXT: cmpb $7, %al
141 ; X86-NEXT: movl $7, %eax
142 ; X86-NEXT: cmovll %ecx, %eax
143 ; X86-NEXT: cmpb $-7, %al
144 ; X86-NEXT: movl $248, %ecx
145 ; X86-NEXT: cmovgel %eax, %ecx
146 ; X86-NEXT: movsbl %cl, %eax
151 ; X64-NEXT: addb %sil, %dil
152 ; X64-NEXT: movzbl %dil, %eax
153 ; X64-NEXT: cmpb $7, %al
154 ; X64-NEXT: movl $7, %ecx
155 ; X64-NEXT: cmovll %eax, %ecx
156 ; X64-NEXT: cmpb $-7, %cl
157 ; X64-NEXT: movl $248, %eax
158 ; X64-NEXT: cmovgel %ecx, %eax
159 ; X64-NEXT: movsbl %al, %eax
161 %tmp = call i4 @llvm.sadd.sat.i4(i4 %x, i4 %y);
165 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
168 ; X86-NEXT: pushl %ebx
169 ; X86-NEXT: pushl %edi
170 ; X86-NEXT: pushl %esi
171 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
172 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
173 ; X86-NEXT: leal (%ecx,%eax), %esi
174 ; X86-NEXT: sarl $31, %esi
175 ; X86-NEXT: addl $-2147483648, %esi # imm = 0x80000000
176 ; X86-NEXT: addl %eax, %ecx
177 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
178 ; X86-NEXT: cmovol %esi, %ecx
179 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
180 ; X86-NEXT: leal (%edx,%eax), %edi
181 ; X86-NEXT: sarl $31, %edi
182 ; X86-NEXT: addl $-2147483648, %edi # imm = 0x80000000
183 ; X86-NEXT: addl %eax, %edx
184 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
185 ; X86-NEXT: cmovol %edi, %edx
186 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
187 ; X86-NEXT: leal (%esi,%eax), %ebx
188 ; X86-NEXT: sarl $31, %ebx
189 ; X86-NEXT: addl $-2147483648, %ebx # imm = 0x80000000
190 ; X86-NEXT: addl %eax, %esi
191 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
192 ; X86-NEXT: cmovol %ebx, %esi
193 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
194 ; X86-NEXT: leal (%edi,%eax), %ebx
195 ; X86-NEXT: sarl $31, %ebx
196 ; X86-NEXT: addl $-2147483648, %ebx # imm = 0x80000000
197 ; X86-NEXT: addl %eax, %edi
198 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
199 ; X86-NEXT: cmovol %ebx, %edi
200 ; X86-NEXT: movl %ecx, 12(%eax)
201 ; X86-NEXT: movl %edx, 8(%eax)
202 ; X86-NEXT: movl %esi, 4(%eax)
203 ; X86-NEXT: movl %edi, (%eax)
204 ; X86-NEXT: popl %esi
205 ; X86-NEXT: popl %edi
206 ; X86-NEXT: popl %ebx
211 ; X64-NEXT: pxor %xmm2, %xmm2
212 ; X64-NEXT: pcmpgtd %xmm1, %xmm2
213 ; X64-NEXT: paddd %xmm0, %xmm1
214 ; X64-NEXT: pcmpgtd %xmm1, %xmm0
215 ; X64-NEXT: pxor %xmm2, %xmm0
216 ; X64-NEXT: movdqa %xmm0, %xmm2
217 ; X64-NEXT: pandn %xmm1, %xmm2
218 ; X64-NEXT: psrad $31, %xmm1
219 ; X64-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
220 ; X64-NEXT: pand %xmm1, %xmm0
221 ; X64-NEXT: por %xmm2, %xmm0
223 %tmp = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %x, <4 x i32> %y);