Reverted commit #147601 upon Evan's request.
[oota-llvm.git] / test / CodeGen / X86 / brcond.ll
1 ; RUN: llc < %s -mtriple=i386-apple-darwin10 -mcpu=penryn | FileCheck %s
2
3 ; rdar://7475489
4
5 define i32 @test1(i32 %a, i32 %b) nounwind ssp {
6 entry:
7 ; CHECK: test1:
8 ; CHECK: xorb
9 ; CHECK-NOT: andb
10 ; CHECK-NOT: shrb
11 ; CHECK: testb $64
12   %0 = and i32 %a, 16384
13   %1 = icmp ne i32 %0, 0
14   %2 = and i32 %b, 16384
15   %3 = icmp ne i32 %2, 0
16   %4 = xor i1 %1, %3
17   br i1 %4, label %bb1, label %bb
18
19 bb:                                               ; preds = %entry
20   %5 = tail call i32 (...)* @foo() nounwind       ; <i32> [#uses=1]
21   ret i32 %5
22
23 bb1:                                              ; preds = %entry
24   %6 = tail call i32 (...)* @bar() nounwind       ; <i32> [#uses=1]
25   ret i32 %6
26 }
27
28 declare i32 @foo(...)
29
30 declare i32 @bar(...)
31
32
33
34 ; PR3351 - (P == 0) & (Q == 0) -> (P|Q) == 0
35 define i32 @test2(i32* %P, i32* %Q) nounwind ssp {
36 entry:
37   %a = icmp eq i32* %P, null                    ; <i1> [#uses=1]
38   %b = icmp eq i32* %Q, null                    ; <i1> [#uses=1]
39   %c = and i1 %a, %b
40   br i1 %c, label %bb1, label %return
41
42 bb1:                                              ; preds = %entry
43   ret i32 4
44
45 return:                                           ; preds = %entry
46   ret i32 192
47 ; CHECK: test2:
48 ; CHECK:        movl    4(%esp), %eax
49 ; CHECK-NEXT:   orl     8(%esp), %eax
50 ; CHECK-NEXT:   jne     LBB1_2
51 }
52
53 ; PR3351 - (P != 0) | (Q != 0) -> (P|Q) != 0
54 define i32 @test3(i32* %P, i32* %Q) nounwind ssp {
55 entry:
56   %a = icmp ne i32* %P, null                    ; <i1> [#uses=1]
57   %b = icmp ne i32* %Q, null                    ; <i1> [#uses=1]
58   %c = or i1 %a, %b
59   br i1 %c, label %bb1, label %return
60
61 bb1:                                              ; preds = %entry
62   ret i32 4
63
64 return:                                           ; preds = %entry
65   ret i32 192
66 ; CHECK: test3:
67 ; CHECK:        movl    4(%esp), %eax
68 ; CHECK-NEXT:   orl     8(%esp), %eax
69 ; CHECK-NEXT:   je      LBB2_2
70 }
71
72 ; <rdar://problem/7598384>:
73 ;
74 ;    jCC  L1
75 ;    jmp  L2
76 ; L1:
77 ;   ...
78 ; L2:
79 ;   ...
80 ;
81 ; to:
82
83 ;    jnCC L2
84 ; L1:
85 ;   ...
86 ; L2:
87 ;   ...
88 define float @test4(float %x, float %y) nounwind readnone optsize ssp {
89 entry:
90   %0 = fpext float %x to double                   ; <double> [#uses=1]
91   %1 = fpext float %y to double                   ; <double> [#uses=1]
92   %2 = fmul double %0, %1                         ; <double> [#uses=3]
93   %3 = fcmp oeq double %2, 0.000000e+00           ; <i1> [#uses=1]
94   br i1 %3, label %bb2, label %bb1
95
96 ; CHECK:      jne
97 ; CHECK-NEXT: jnp
98 ; CHECK-NOT:  jmp
99 ; CHECK:      LBB
100
101 bb1:                                              ; preds = %entry
102   %4 = fadd double %2, -1.000000e+00              ; <double> [#uses=1]
103   br label %bb2
104
105 bb2:                                              ; preds = %entry, %bb1
106   %.0.in = phi double [ %4, %bb1 ], [ %2, %entry ] ; <double> [#uses=1]
107   %.0 = fptrunc double %.0.in to float            ; <float> [#uses=1]
108   ret float %.0
109 }
110