1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefixes=X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefixes=X64
5 %WideUInt32 = type { i32, i32 }
7 define void @PR25858_i32(%WideUInt32* sret, %WideUInt32*, %WideUInt32*) nounwind {
8 ; X86-LABEL: PR25858_i32:
10 ; X86-NEXT: pushl %esi
11 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
12 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
13 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
14 ; X86-NEXT: movl (%edx), %esi
15 ; X86-NEXT: movl 4(%edx), %edx
16 ; X86-NEXT: subl (%ecx), %esi
17 ; X86-NEXT: sbbl 4(%ecx), %edx
18 ; X86-NEXT: movl %edx, 4(%eax)
19 ; X86-NEXT: movl %esi, (%eax)
23 ; X64-LABEL: PR25858_i32:
24 ; X64: # %bb.0: # %top
25 ; X64-NEXT: movq %rdi, %rax
26 ; X64-NEXT: movl (%rsi), %ecx
27 ; X64-NEXT: movl 4(%rsi), %esi
28 ; X64-NEXT: subl (%rdx), %ecx
29 ; X64-NEXT: sbbl 4(%rdx), %esi
30 ; X64-NEXT: movl %esi, 4(%rdi)
31 ; X64-NEXT: movl %ecx, (%rdi)
34 %3 = bitcast %WideUInt32* %1 to i32*
35 %4 = load i32, i32* %3, align 4
36 %5 = bitcast %WideUInt32* %2 to i32*
37 %6 = load i32, i32* %5, align 4
39 %8 = call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %4, i32 %6)
40 %9 = extractvalue { i32, i1 } %8, 1
41 %10 = getelementptr inbounds %WideUInt32, %WideUInt32* %1, i32 0, i32 1
42 %11 = load i32, i32* %10, align 8
43 %12 = getelementptr inbounds %WideUInt32, %WideUInt32* %2, i32 0, i32 1
44 %13 = load i32, i32* %12, align 8
45 %14 = sub i32 %11, %13
46 %.neg1 = sext i1 %9 to i32
47 %15 = add i32 %14, %.neg1
48 %16 = insertvalue %WideUInt32 undef, i32 %7, 0
49 %17 = insertvalue %WideUInt32 %16, i32 %15, 1
50 store %WideUInt32 %17, %WideUInt32* %0, align 4
54 declare { i32, i1 } @llvm.usub.with.overflow.i32(i32, i32)
56 %WideUInt64 = type { i64, i64 }
58 define void @PR25858_i64(%WideUInt64* sret, %WideUInt64*, %WideUInt64*) nounwind {
59 ; X86-LABEL: PR25858_i64:
60 ; X86: # %bb.0: # %top
61 ; X86-NEXT: pushl %ebp
62 ; X86-NEXT: pushl %ebx
63 ; X86-NEXT: pushl %edi
64 ; X86-NEXT: pushl %esi
65 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
66 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
67 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
68 ; X86-NEXT: movl (%edx), %esi
69 ; X86-NEXT: movl 4(%edx), %edi
70 ; X86-NEXT: subl (%ecx), %esi
71 ; X86-NEXT: sbbl 4(%ecx), %edi
73 ; X86-NEXT: movl 12(%edx), %ebp
74 ; X86-NEXT: movl 8(%edx), %edx
75 ; X86-NEXT: subl 8(%ecx), %edx
76 ; X86-NEXT: sbbl 12(%ecx), %ebp
77 ; X86-NEXT: movzbl %bl, %ecx
78 ; X86-NEXT: subl %ecx, %edx
79 ; X86-NEXT: sbbl $0, %ebp
80 ; X86-NEXT: movl %esi, (%eax)
81 ; X86-NEXT: movl %edi, 4(%eax)
82 ; X86-NEXT: movl %edx, 8(%eax)
83 ; X86-NEXT: movl %ebp, 12(%eax)
90 ; X64-LABEL: PR25858_i64:
91 ; X64: # %bb.0: # %top
92 ; X64-NEXT: movq %rdi, %rax
93 ; X64-NEXT: movq (%rsi), %rcx
94 ; X64-NEXT: movq 8(%rsi), %rsi
95 ; X64-NEXT: subq (%rdx), %rcx
96 ; X64-NEXT: sbbq 8(%rdx), %rsi
97 ; X64-NEXT: movq %rsi, 8(%rdi)
98 ; X64-NEXT: movq %rcx, (%rdi)
101 %3 = bitcast %WideUInt64* %1 to i64*
102 %4 = load i64, i64* %3, align 8
103 %5 = bitcast %WideUInt64* %2 to i64*
104 %6 = load i64, i64* %5, align 8
106 %8 = call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %4, i64 %6)
107 %9 = extractvalue { i64, i1 } %8, 1
108 %10 = getelementptr inbounds %WideUInt64, %WideUInt64* %1, i64 0, i32 1
109 %11 = load i64, i64* %10, align 8
110 %12 = getelementptr inbounds %WideUInt64, %WideUInt64* %2, i64 0, i32 1
111 %13 = load i64, i64* %12, align 8
112 %14 = sub i64 %11, %13
113 %.neg1 = sext i1 %9 to i64
114 %15 = add i64 %14, %.neg1
115 %16 = insertvalue %WideUInt64 undef, i64 %7, 0
116 %17 = insertvalue %WideUInt64 %16, i64 %15, 1
117 store %WideUInt64 %17, %WideUInt64* %0, align 8
121 declare { i64, i1 } @llvm.usub.with.overflow.i64(i64, i64)
123 ; PR24545 less_than_ideal()
124 define i8 @PR24545(i32, i32, i32* nocapture readonly) {
125 ; X86-LABEL: PR24545:
127 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
128 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
129 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
130 ; X86-NEXT: cmpl (%ecx), %edx
131 ; X86-NEXT: sbbl 4(%ecx), %eax
135 ; X64-LABEL: PR24545:
137 ; X64-NEXT: cmpl (%rdx), %edi
138 ; X64-NEXT: sbbl 4(%rdx), %esi
141 %4 = load i32, i32* %2
142 %5 = icmp ugt i32 %4, %0
143 %6 = zext i1 %5 to i8
144 %7 = getelementptr inbounds i32, i32* %2, i32 1
145 %8 = load i32, i32* %7
146 %9 = tail call { i8, i32 } @llvm.x86.subborrow.32(i8 %6, i32 %1, i32 %8)
147 %10 = extractvalue { i8, i32 } %9, 0
148 %11 = icmp ne i8 %10, 0
149 %12 = zext i1 %11 to i8
153 define i32 @PR40483_sub1(i32*, i32) nounwind {
154 ; X86-LABEL: PR40483_sub1:
156 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
157 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
158 ; X86-NEXT: subl %eax, (%ecx)
159 ; X86-NEXT: xorl %eax, %eax
162 ; X64-LABEL: PR40483_sub1:
164 ; X64-NEXT: subl %esi, (%rdi)
165 ; X64-NEXT: xorl %eax, %eax
167 %3 = load i32, i32* %0, align 4
168 %4 = tail call { i8, i32 } @llvm.x86.subborrow.32(i8 0, i32 %3, i32 %1)
169 %5 = extractvalue { i8, i32 } %4, 1
170 store i32 %5, i32* %0, align 4
176 define i32 @PR40483_sub2(i32*, i32) nounwind {
177 ; X86-LABEL: PR40483_sub2:
179 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
180 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
181 ; X86-NEXT: subl %eax, (%ecx)
182 ; X86-NEXT: xorl %eax, %eax
185 ; X64-LABEL: PR40483_sub2:
187 ; X64-NEXT: subl %esi, (%rdi)
188 ; X64-NEXT: xorl %eax, %eax
190 %3 = load i32, i32* %0, align 4
192 %5 = tail call { i8, i32 } @llvm.x86.subborrow.32(i8 0, i32 %3, i32 %1)
193 %6 = extractvalue { i8, i32 } %5, 1
194 store i32 %6, i32* %0, align 4
199 define i32 @PR40483_sub3(i32*, i32) nounwind {
200 ; X86-LABEL: PR40483_sub3:
202 ; X86-NEXT: pushl %esi
203 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
204 ; X86-NEXT: movl (%eax), %edx
205 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
206 ; X86-NEXT: movl %edx, %ecx
207 ; X86-NEXT: subl %esi, %ecx
208 ; X86-NEXT: subl %esi, %edx
209 ; X86-NEXT: movl %edx, (%eax)
210 ; X86-NEXT: jae .LBB5_1
212 ; X86-NEXT: xorl %eax, %eax
213 ; X86-NEXT: popl %esi
216 ; X86-NEXT: movl %ecx, %eax
217 ; X86-NEXT: negl %eax
218 ; X86-NEXT: orl %ecx, %eax
219 ; X86-NEXT: popl %esi
222 ; X64-LABEL: PR40483_sub3:
224 ; X64-NEXT: movl (%rdi), %ecx
225 ; X64-NEXT: movl %ecx, %eax
226 ; X64-NEXT: subl %esi, %eax
227 ; X64-NEXT: movl %eax, %edx
228 ; X64-NEXT: negl %edx
229 ; X64-NEXT: orl %eax, %edx
230 ; X64-NEXT: xorl %eax, %eax
231 ; X64-NEXT: subl %esi, %ecx
232 ; X64-NEXT: movl %ecx, (%rdi)
233 ; X64-NEXT: cmovael %edx, %eax
235 %3 = load i32, i32* %0, align 8
236 %4 = tail call { i8, i32 } @llvm.x86.subborrow.32(i8 0, i32 %3, i32 %1)
237 %5 = extractvalue { i8, i32 } %4, 1
238 store i32 %5, i32* %0, align 8
239 %6 = extractvalue { i8, i32 } %4, 0
240 %7 = icmp eq i8 %6, 0
243 %10 = select i1 %7, i32 %9, i32 0
247 define i32 @PR40483_sub4(i32*, i32) nounwind {
248 ; X86-LABEL: PR40483_sub4:
250 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
251 ; X86-NEXT: movl (%edx), %ecx
252 ; X86-NEXT: xorl %eax, %eax
253 ; X86-NEXT: subl {{[0-9]+}}(%esp), %ecx
254 ; X86-NEXT: movl %ecx, (%edx)
255 ; X86-NEXT: jae .LBB6_2
257 ; X86-NEXT: movl %ecx, %eax
261 ; X64-LABEL: PR40483_sub4:
263 ; X64-NEXT: movl (%rdi), %eax
264 ; X64-NEXT: xorl %ecx, %ecx
265 ; X64-NEXT: subl %esi, %eax
266 ; X64-NEXT: movl %eax, (%rdi)
267 ; X64-NEXT: cmovael %ecx, %eax
269 %3 = load i32, i32* %0, align 8
270 %4 = tail call { i8, i32 } @llvm.x86.subborrow.32(i8 0, i32 %3, i32 %1)
271 %5 = extractvalue { i8, i32 } %4, 1
272 store i32 %5, i32* %0, align 8
273 %6 = extractvalue { i8, i32 } %4, 0
274 %7 = icmp eq i8 %6, 0
277 %10 = select i1 %7, i32 0, i32 %9
281 ; Verify that a bogus cmov is simplified.
283 define i32 @PR40483_sub5(i32*, i32) nounwind {
284 ; X86-LABEL: PR40483_sub5:
286 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
287 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
288 ; X86-NEXT: subl %eax, (%ecx)
289 ; X86-NEXT: xorl %eax, %eax
292 ; X64-LABEL: PR40483_sub5:
294 ; X64-NEXT: subl %esi, (%rdi)
295 ; X64-NEXT: xorl %eax, %eax
297 %3 = load i32, i32* %0, align 8
298 %4 = tail call { i8, i32 } @llvm.x86.subborrow.32(i8 0, i32 %3, i32 %1)
299 %5 = extractvalue { i8, i32 } %4, 1
300 store i32 %5, i32* %0, align 8
301 %6 = extractvalue { i8, i32 } %4, 0
302 %7 = icmp eq i8 %6, 0
305 %10 = select i1 %7, i32 %9, i32 0
309 define i32 @PR40483_sub6(i32*, i32) nounwind {
310 ; X86-LABEL: PR40483_sub6:
312 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
313 ; X86-NEXT: movl (%edx), %ecx
314 ; X86-NEXT: xorl %eax, %eax
315 ; X86-NEXT: subl {{[0-9]+}}(%esp), %ecx
316 ; X86-NEXT: movl %ecx, (%edx)
317 ; X86-NEXT: jae .LBB8_2
319 ; X86-NEXT: leal (%ecx,%ecx), %eax
323 ; X64-LABEL: PR40483_sub6:
325 ; X64-NEXT: movl (%rdi), %eax
326 ; X64-NEXT: xorl %ecx, %ecx
327 ; X64-NEXT: subl %esi, %eax
328 ; X64-NEXT: movl %eax, (%rdi)
329 ; X64-NEXT: leal (%rax,%rax), %eax
330 ; X64-NEXT: cmovael %ecx, %eax
332 %3 = load i32, i32* %0, align 8
333 %4 = tail call { i8, i32 } @llvm.x86.subborrow.32(i8 0, i32 %3, i32 %1)
334 %5 = extractvalue { i8, i32 } %4, 1
335 store i32 %5, i32* %0, align 8
336 %6 = extractvalue { i8, i32 } %4, 0
337 %7 = icmp eq i8 %6, 0
340 %10 = select i1 %7, i32 0, i32 %9
344 declare { i8, i32 } @llvm.x86.subborrow.32(i8, i32, i32)