Fix a FIXME. _foo.eh symbols are currently always exported so that the linker
[oota-llvm.git] / test / CodeGen / X86 / use-add-flags.ll
1 ; RUN: llc < %s -march=x86-64 -o - | FileCheck %s
2
3 ; Reuse the flags value from the add instructions instead of emitting separate
4 ; testl instructions.
5
6 ; Use the flags on the add.
7
8 ; CHECK: test1:
9 ;      CHECK: addl    (%rdi), %esi
10 ; CHECK-NEXT: movl    %edx, %eax
11 ; CHECK-NEXT: cmovnsl %ecx, %eax
12 ; CHECK-NEXT: ret
13
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]
19         ret i32 %tmp.0
20 }
21
22 declare void @foo(i32)
23
24 ; Don't use the flags result of the and here, since the and has no
25 ; other use. A simple test is better.
26
27 ; CHECK: test2:
28 ; CHECK: testb   $16, %dil
29
30 define void @test2(i32 %x) nounwind {
31   %y = and i32 %x, 16
32   %t = icmp eq i32 %y, 0
33   br i1 %t, label %true, label %false
34 true:
35   call void @foo(i32 %x)
36   ret void
37 false:
38   ret void
39 }
40
41 ; Do use the flags result of the and here, since the and has another use.
42
43 ; CHECK: test3:
44 ;      CHECK: andl    $16, %edi
45 ; CHECK-NEXT: jne
46
47 define void @test3(i32 %x) nounwind {
48   %y = and i32 %x, 16
49   %t = icmp eq i32 %y, 0
50   br i1 %t, label %true, label %false
51 true:
52   call void @foo(i32 %y)
53   ret void
54 false:
55   ret void
56 }