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.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 %ebx
42 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
43 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
44 ; X86-NEXT: subl {{[0-9]+}}(%esp), %eax
45 ; X86-NEXT: sbbl {{[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: xorl %ecx, %ecx
60 ; X64-NEXT: cmpq %rsi, %rdi
62 ; X64-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
63 ; X64-NEXT: addq %rcx, %rax
64 ; X64-NEXT: subq %rsi, %rdi
65 ; X64-NEXT: cmovnoq %rdi, %rax
67 %tmp = call i64 @llvm.ssub.sat.i64(i64 %x, i64 %y)
71 define signext i16 @func16(i16 signext %x, i16 signext %y) nounwind {
74 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
75 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %edx
76 ; X86-NEXT: xorl %ecx, %ecx
77 ; X86-NEXT: cmpw %dx, %ax
79 ; X86-NEXT: addl $32767, %ecx # imm = 0x7FFF
80 ; X86-NEXT: subw %dx, %ax
81 ; X86-NEXT: cmovol %ecx, %eax
82 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
87 ; X64-NEXT: xorl %eax, %eax
88 ; X64-NEXT: cmpw %si, %di
90 ; X64-NEXT: addl $32767, %eax # imm = 0x7FFF
91 ; X64-NEXT: subw %si, %di
92 ; X64-NEXT: cmovnol %edi, %eax
93 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
95 %tmp = call i16 @llvm.ssub.sat.i16(i16 %x, i16 %y)
99 define signext i8 @func8(i8 signext %x, i8 signext %y) nounwind {
102 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
103 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %edx
104 ; X86-NEXT: xorl %ecx, %ecx
105 ; X86-NEXT: cmpb %dl, %al
106 ; X86-NEXT: setns %cl
107 ; X86-NEXT: addl $127, %ecx
108 ; X86-NEXT: subb %dl, %al
109 ; X86-NEXT: movzbl %al, %eax
110 ; X86-NEXT: cmovol %ecx, %eax
111 ; X86-NEXT: # kill: def $al killed $al killed $eax
116 ; X64-NEXT: xorl %ecx, %ecx
117 ; X64-NEXT: cmpb %sil, %dil
118 ; X64-NEXT: setns %cl
119 ; X64-NEXT: addl $127, %ecx
120 ; X64-NEXT: subb %sil, %dil
121 ; X64-NEXT: movzbl %dil, %eax
122 ; X64-NEXT: cmovol %ecx, %eax
123 ; X64-NEXT: # kill: def $al killed $al killed $eax
125 %tmp = call i8 @llvm.ssub.sat.i8(i8 %x, i8 %y)
129 define signext i4 @func3(i4 signext %x, i4 signext %y) nounwind {
132 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
133 ; X86-NEXT: subb {{[0-9]+}}(%esp), %al
134 ; X86-NEXT: movzbl %al, %ecx
135 ; X86-NEXT: cmpb $7, %al
136 ; X86-NEXT: movl $7, %eax
137 ; X86-NEXT: cmovll %ecx, %eax
138 ; X86-NEXT: cmpb $-7, %al
139 ; X86-NEXT: movl $248, %ecx
140 ; X86-NEXT: cmovgel %eax, %ecx
141 ; X86-NEXT: movsbl %cl, %eax
146 ; X64-NEXT: subb %sil, %dil
147 ; X64-NEXT: movzbl %dil, %eax
148 ; X64-NEXT: cmpb $7, %al
149 ; X64-NEXT: movl $7, %ecx
150 ; X64-NEXT: cmovll %eax, %ecx
151 ; X64-NEXT: cmpb $-7, %cl
152 ; X64-NEXT: movl $248, %eax
153 ; X64-NEXT: cmovgel %ecx, %eax
154 ; X64-NEXT: movsbl %al, %eax
156 %tmp = call i4 @llvm.ssub.sat.i4(i4 %x, i4 %y)
160 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
163 ; X86-NEXT: pushl %ebx
164 ; X86-NEXT: pushl %edi
165 ; X86-NEXT: pushl %esi
166 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
167 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
168 ; X86-NEXT: xorl %eax, %eax
169 ; X86-NEXT: cmpl %edx, %ecx
170 ; X86-NEXT: setns %al
171 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
172 ; X86-NEXT: subl %edx, %ecx
173 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
174 ; X86-NEXT: cmovol %eax, %ecx
175 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
176 ; X86-NEXT: xorl %eax, %eax
177 ; X86-NEXT: cmpl %esi, %edx
178 ; X86-NEXT: setns %al
179 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
180 ; X86-NEXT: subl %esi, %edx
181 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
182 ; X86-NEXT: cmovol %eax, %edx
183 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
184 ; X86-NEXT: xorl %eax, %eax
185 ; X86-NEXT: cmpl %edi, %esi
186 ; X86-NEXT: setns %al
187 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
188 ; X86-NEXT: subl %edi, %esi
189 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
190 ; X86-NEXT: cmovol %eax, %esi
191 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
192 ; X86-NEXT: xorl %ebx, %ebx
193 ; X86-NEXT: cmpl %eax, %edi
194 ; X86-NEXT: setns %bl
195 ; X86-NEXT: addl $2147483647, %ebx # imm = 0x7FFFFFFF
196 ; X86-NEXT: subl %eax, %edi
197 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
198 ; X86-NEXT: cmovol %ebx, %edi
199 ; X86-NEXT: movl %ecx, 12(%eax)
200 ; X86-NEXT: movl %edx, 8(%eax)
201 ; X86-NEXT: movl %esi, 4(%eax)
202 ; X86-NEXT: movl %edi, (%eax)
203 ; X86-NEXT: popl %esi
204 ; X86-NEXT: popl %edi
205 ; X86-NEXT: popl %ebx
210 ; X64-NEXT: pxor %xmm2, %xmm2
211 ; X64-NEXT: movdqa %xmm0, %xmm3
212 ; X64-NEXT: psubd %xmm1, %xmm3
213 ; X64-NEXT: pcmpgtd %xmm2, %xmm1
214 ; X64-NEXT: pcmpgtd %xmm3, %xmm0
215 ; X64-NEXT: pxor %xmm1, %xmm0
216 ; X64-NEXT: movdqa %xmm0, %xmm1
217 ; X64-NEXT: pandn %xmm3, %xmm1
218 ; X64-NEXT: psrad $31, %xmm3
219 ; X64-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm3
220 ; X64-NEXT: pand %xmm3, %xmm0
221 ; X64-NEXT: por %xmm1, %xmm0
223 %tmp = call <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %x, <4 x i32> %y)