llvm.org GIT mirror llvm / 91b97f6
[x86] add test for sub-with-flags opportunity (PR40483); NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366019 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 7 months ago
1 changed file(s) with 46 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
279279
280280 ; Verify that a bogus cmov is simplified.
281281
282 define i32 @PR40483_sub5(i32*, i32) {
282 define i32 @PR40483_sub5(i32*, i32) nounwind {
283283 ; X86-LABEL: PR40483_sub5:
284284 ; X86: # %bb.0:
285285 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
305305 ret i32 %10
306306 }
307307
308 define i32 @PR40483_sub6(i32*, i32) nounwind {
309 ; X86-LABEL: PR40483_sub6:
310 ; X86: # %bb.0:
311 ; X86-NEXT: pushl %edi
312 ; X86-NEXT: pushl %esi
313 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
314 ; X86-NEXT: movl (%edx), %esi
315 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
316 ; X86-NEXT: movl %esi, %ecx
317 ; X86-NEXT: subl %edi, %ecx
318 ; X86-NEXT: xorl %eax, %eax
319 ; X86-NEXT: subl %edi, %esi
320 ; X86-NEXT: movl %esi, (%edx)
321 ; X86-NEXT: jae .LBB8_2
322 ; X86-NEXT: # %bb.1:
323 ; X86-NEXT: addl %ecx, %ecx
324 ; X86-NEXT: movl %ecx, %eax
325 ; X86-NEXT: .LBB8_2:
326 ; X86-NEXT: popl %esi
327 ; X86-NEXT: popl %edi
328 ; X86-NEXT: retl
329 ;
330 ; X64-LABEL: PR40483_sub6:
331 ; X64: # %bb.0:
332 ; X64-NEXT: movl (%rdi), %ecx
333 ; X64-NEXT: movl %ecx, %edx
334 ; X64-NEXT: subl %esi, %edx
335 ; X64-NEXT: addl %edx, %edx
336 ; X64-NEXT: xorl %eax, %eax
337 ; X64-NEXT: subl %esi, %ecx
338 ; X64-NEXT: movl %ecx, (%rdi)
339 ; X64-NEXT: cmovbl %edx, %eax
340 ; X64-NEXT: retq
341 %3 = load i32, i32* %0, align 8
342 %4 = tail call { i8, i32 } @llvm.x86.subborrow.32(i8 0, i32 %3, i32 %1)
343 %5 = extractvalue { i8, i32 } %4, 1
344 store i32 %5, i32* %0, align 8
345 %6 = extractvalue { i8, i32 } %4, 0
346 %7 = icmp eq i8 %6, 0
347 %8 = sub i32 %3, %1
348 %9 = add i32 %8, %5
349 %10 = select i1 %7, i32 0, i32 %9
350 ret i32 %10
351 }
352
308353 declare { i8, i32 } @llvm.x86.subborrow.32(i8, i32, i32)