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 i32 @llvm.ssub.sat.i32 (i32, i32)
7 declare i64 @llvm.ssub.sat.i64 (i64, i64)
8 declare <4 x i32> @llvm.ssub.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: subl %edx, %esi
20 ; X86-NEXT: addl $2147483647, %ecx # imm = 0x7FFFFFFF
21 ; X86-NEXT: subl %edx, %eax
22 ; X86-NEXT: cmovol %ecx, %eax
28 ; X64-NEXT: xorl %eax, %eax
29 ; X64-NEXT: movl %edi, %ecx
30 ; X64-NEXT: subl %esi, %ecx
32 ; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
33 ; X64-NEXT: subl %esi, %edi
34 ; X64-NEXT: cmovnol %edi, %eax
36 %tmp = call i32 @llvm.ssub.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: subl {{[0-9]+}}(%esp), %edi
51 ; X86-NEXT: movl %ebx, %ebp
52 ; X86-NEXT: sbbl %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: subq %rsi, %rax
83 ; X64-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
84 ; X64-NEXT: addq %rcx, %rax
85 ; X64-NEXT: subq %rsi, %rdi
86 ; X64-NEXT: cmovnoq %rdi, %rax
88 %tmp = call i64 @llvm.ssub.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: xorl %ecx, %ecx
100 ; X86-NEXT: movb %al, %ah
101 ; X86-NEXT: subb %dl, %ah
102 ; X86-NEXT: setns %cl
103 ; X86-NEXT: addl $127, %ecx
104 ; X86-NEXT: subb %dl, %al
105 ; X86-NEXT: movzbl %al, %eax
106 ; X86-NEXT: cmovol %ecx, %eax
107 ; X86-NEXT: sarb $4, %al
108 ; X86-NEXT: # kill: def $al killed $al killed $eax
113 ; X64-NEXT: shlb $4, %sil
114 ; X64-NEXT: shlb $4, %dil
115 ; X64-NEXT: xorl %ecx, %ecx
116 ; X64-NEXT: movl %edi, %eax
117 ; X64-NEXT: subb %sil, %al
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: sarb $4, %al
124 ; X64-NEXT: # kill: def $al killed $al killed $eax
126 %tmp = call i4 @llvm.ssub.sat.i4(i4 %x, i4 %y)
130 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
133 ; X86-NEXT: pushl %ebp
134 ; X86-NEXT: pushl %ebx
135 ; X86-NEXT: pushl %edi
136 ; X86-NEXT: pushl %esi
137 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
138 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
139 ; X86-NEXT: xorl %eax, %eax
140 ; X86-NEXT: movl %ecx, %esi
141 ; X86-NEXT: subl %edx, %esi
142 ; X86-NEXT: setns %al
143 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
144 ; X86-NEXT: subl %edx, %ecx
145 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
146 ; X86-NEXT: cmovol %eax, %ecx
147 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
148 ; X86-NEXT: xorl %eax, %eax
149 ; X86-NEXT: movl %edx, %edi
150 ; X86-NEXT: subl %esi, %edi
151 ; X86-NEXT: setns %al
152 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
153 ; X86-NEXT: subl %esi, %edx
154 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
155 ; X86-NEXT: cmovol %eax, %edx
156 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
157 ; X86-NEXT: xorl %eax, %eax
158 ; X86-NEXT: movl %esi, %ebx
159 ; X86-NEXT: subl %edi, %ebx
160 ; X86-NEXT: setns %al
161 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
162 ; X86-NEXT: subl %edi, %esi
163 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
164 ; X86-NEXT: cmovol %eax, %esi
165 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
166 ; X86-NEXT: xorl %ebx, %ebx
167 ; X86-NEXT: movl %edi, %ebp
168 ; X86-NEXT: subl %eax, %ebp
169 ; X86-NEXT: setns %bl
170 ; X86-NEXT: addl $2147483647, %ebx # imm = 0x7FFFFFFF
171 ; X86-NEXT: subl %eax, %edi
172 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
173 ; X86-NEXT: cmovol %ebx, %edi
174 ; X86-NEXT: movl %ecx, 12(%eax)
175 ; X86-NEXT: movl %edx, 8(%eax)
176 ; X86-NEXT: movl %esi, 4(%eax)
177 ; X86-NEXT: movl %edi, (%eax)
178 ; X86-NEXT: popl %esi
179 ; X86-NEXT: popl %edi
180 ; X86-NEXT: popl %ebx
181 ; X86-NEXT: popl %ebp
186 ; X64-NEXT: movdqa %xmm0, %xmm2
187 ; X64-NEXT: pxor %xmm3, %xmm3
188 ; X64-NEXT: pxor %xmm0, %xmm0
189 ; X64-NEXT: pcmpgtd %xmm1, %xmm0
190 ; X64-NEXT: pcmpeqd %xmm4, %xmm4
191 ; X64-NEXT: pxor %xmm4, %xmm0
192 ; X64-NEXT: pxor %xmm5, %xmm5
193 ; X64-NEXT: pcmpgtd %xmm2, %xmm5
194 ; X64-NEXT: pxor %xmm4, %xmm5
195 ; X64-NEXT: pcmpeqd %xmm5, %xmm0
196 ; X64-NEXT: psubd %xmm1, %xmm2
197 ; X64-NEXT: pcmpgtd %xmm2, %xmm3
198 ; X64-NEXT: movdqa %xmm3, %xmm1
199 ; X64-NEXT: pxor %xmm4, %xmm1
200 ; X64-NEXT: pcmpeqd %xmm5, %xmm1
201 ; X64-NEXT: pxor %xmm4, %xmm1
202 ; X64-NEXT: pandn %xmm1, %xmm0
203 ; X64-NEXT: movdqa %xmm3, %xmm1
204 ; X64-NEXT: pandn {{.*}}(%rip), %xmm1
205 ; X64-NEXT: psrld $1, %xmm3
206 ; X64-NEXT: por %xmm1, %xmm3
207 ; X64-NEXT: pand %xmm0, %xmm3
208 ; X64-NEXT: pandn %xmm2, %xmm0
209 ; X64-NEXT: por %xmm3, %xmm0
211 %tmp = call <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %x, <4 x i32> %y)