1 ; RUN: llc < %s -march=x86-64 -o - | FileCheck %s
3 ; Reuse the flags value from the add instructions instead of emitting separate
6 ; Use the flags on the add.
9 ; CHECK: addl (%rdi), %esi
10 ; CHECK-NEXT: movl %edx, %eax
11 ; CHECK-NEXT: cmovnsl %ecx, %eax
14 define i32 @test1(i32* %x, i32 %y, i32 %a, i32 %b) nounwind {
15 %tmp2 = load i32* %x, align 4 ; <i32> [#uses=1]
16 %tmp4 = add i32 %tmp2, %y ; <i32> [#uses=1]
17 %tmp5 = icmp slt i32 %tmp4, 0 ; <i1> [#uses=1]
18 %tmp.0 = select i1 %tmp5, i32 %a, i32 %b ; <i32> [#uses=1]
22 declare void @foo(i32)
24 ; Don't use the flags result of the and here, since the and has no
25 ; other use. A simple test is better.
28 ; CHECK: testb $16, %dil
30 define void @test2(i32 %x) nounwind {
32 %t = icmp eq i32 %y, 0
33 br i1 %t, label %true, label %false
35 call void @foo(i32 %x)
41 ; Do use the flags result of the and here, since the and has another use.
44 ; CHECK: andl $16, %edi
47 define void @test3(i32 %x) nounwind {
49 %t = icmp eq i32 %y, 0
50 br i1 %t, label %true, label %false
52 call void @foo(i32 %y)