1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefix=LNX
3 ; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s --check-prefix=WIN
5 ; Reuse the flags value from the add instructions instead of emitting separate
8 ; Use the flags on the add.
10 define i32 @test1(ptr %x, i32 %y, i32 %a, i32 %b) nounwind {
13 ; LNX-NEXT: movl %edx, %eax
14 ; LNX-NEXT: addl (%rdi), %esi
15 ; LNX-NEXT: cmovnsl %ecx, %eax
20 ; WIN-NEXT: movl %r8d, %eax
21 ; WIN-NEXT: addl (%rcx), %edx
22 ; WIN-NEXT: cmovnsl %r9d, %eax
24 %tmp2 = load i32, ptr %x, align 4 ; <i32> [#uses=1]
25 %tmp4 = add i32 %tmp2, %y ; <i32> [#uses=1]
26 %tmp5 = icmp slt i32 %tmp4, 0 ; <i1> [#uses=1]
27 %tmp.0 = select i1 %tmp5, i32 %a, i32 %b ; <i32> [#uses=1]
31 declare void @foo(i32)
33 ; Don't use the flags result of the and here, since the and has no
34 ; other use. A simple test is better.
36 define void @test2(i32 %x) nounwind {
39 ; LNX-NEXT: testb $16, %dil
40 ; LNX-NEXT: jne .LBB1_2
41 ; LNX-NEXT: # %bb.1: # %true
42 ; LNX-NEXT: pushq %rax
43 ; LNX-NEXT: callq foo@PLT
45 ; LNX-NEXT: .LBB1_2: # %false
50 ; WIN-NEXT: subq $40, %rsp
51 ; WIN-NEXT: testb $16, %cl
52 ; WIN-NEXT: jne .LBB1_2
53 ; WIN-NEXT: # %bb.1: # %true
55 ; WIN-NEXT: .LBB1_2: # %false
56 ; WIN-NEXT: addq $40, %rsp
59 %t = icmp eq i32 %y, 0
60 br i1 %t, label %true, label %false
62 call void @foo(i32 %x)
68 ; Do use the flags result of the and here, since the and has another use.
70 define void @test3(i32 %x) nounwind {
73 ; LNX-NEXT: andl $16, %edi
74 ; LNX-NEXT: jne .LBB2_2
75 ; LNX-NEXT: # %bb.1: # %true
76 ; LNX-NEXT: pushq %rax
77 ; LNX-NEXT: callq foo@PLT
79 ; LNX-NEXT: .LBB2_2: # %false
84 ; WIN-NEXT: subq $40, %rsp
85 ; WIN-NEXT: andl $16, %ecx
86 ; WIN-NEXT: jne .LBB2_2
87 ; WIN-NEXT: # %bb.1: # %true
89 ; WIN-NEXT: .LBB2_2: # %false
90 ; WIN-NEXT: addq $40, %rsp
93 %t = icmp eq i32 %y, 0
94 br i1 %t, label %true, label %false
96 call void @foo(i32 %y)