1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=ALL
3
4define i8 @test_i8(i32 %a, i8 %f, i8 %t) {
5; ALL-LABEL: test_i8:
6; ALL:       # %bb.0: # %entry
7; ALL-NEXT:    xorl %ecx, %ecx
8; ALL-NEXT:    cmpl %ecx, %edi
9; ALL-NEXT:    setg %cl
10; ALL-NEXT:    testb $1, %cl
11; ALL-NEXT:    je .LBB0_2
12; ALL-NEXT:  # %bb.1:
13; ALL-NEXT:    movl %esi, %eax
14; ALL-NEXT:    # kill: def $al killed $al killed $eax
15; ALL-NEXT:    retq
16; ALL-NEXT:  .LBB0_2: # %cond.false
17; ALL-NEXT:    movl %edx, %eax
18; ALL-NEXT:    # kill: def $al killed $al killed $eax
19; ALL-NEXT:    retq
20entry:
21  %cmp = icmp sgt i32 %a, 0
22  br i1 %cmp, label %cond.true, label %cond.false
23
24cond.true:                                        ; preds = %entry
25  br label %cond.end
26
27cond.false:                                       ; preds = %entry
28  br label %cond.end
29
30cond.end:                                         ; preds = %cond.false, %cond.true
31  %cond = phi i8 [ %f, %cond.true ], [ %t, %cond.false ]
32  ret i8 %cond
33}
34
35define i16 @test_i16(i32 %a, i16 %f, i16 %t) {
36; ALL-LABEL: test_i16:
37; ALL:       # %bb.0: # %entry
38; ALL-NEXT:    xorl %ecx, %ecx
39; ALL-NEXT:    cmpl %ecx, %edi
40; ALL-NEXT:    setg %cl
41; ALL-NEXT:    testb $1, %cl
42; ALL-NEXT:    je .LBB1_2
43; ALL-NEXT:  # %bb.1:
44; ALL-NEXT:    movl %esi, %eax
45; ALL-NEXT:    # kill: def $ax killed $ax killed $eax
46; ALL-NEXT:    retq
47; ALL-NEXT:  .LBB1_2: # %cond.false
48; ALL-NEXT:    movl %edx, %eax
49; ALL-NEXT:    # kill: def $ax killed $ax killed $eax
50; ALL-NEXT:    retq
51entry:
52  %cmp = icmp sgt i32 %a, 0
53  br i1 %cmp, label %cond.true, label %cond.false
54
55cond.true:                                        ; preds = %entry
56  br label %cond.end
57
58cond.false:                                       ; preds = %entry
59  br label %cond.end
60
61cond.end:                                         ; preds = %cond.false, %cond.true
62  %cond = phi i16 [ %f, %cond.true ], [ %t, %cond.false ]
63  ret i16 %cond
64}
65
66define i32 @test_i32(i32 %a, i32 %f, i32 %t) {
67; ALL-LABEL: test_i32:
68; ALL:       # %bb.0: # %entry
69; ALL-NEXT:    movl %esi, %eax
70; ALL-NEXT:    xorl %ecx, %ecx
71; ALL-NEXT:    cmpl %ecx, %edi
72; ALL-NEXT:    setg %cl
73; ALL-NEXT:    testb $1, %cl
74; ALL-NEXT:    je .LBB2_1
75; ALL-NEXT:  # %bb.2: # %cond.end
76; ALL-NEXT:    retq
77; ALL-NEXT:  .LBB2_1: # %cond.false
78; ALL-NEXT:    movl %edx, %eax
79; ALL-NEXT:    retq
80entry:
81  %cmp = icmp sgt i32 %a, 0
82  br i1 %cmp, label %cond.true, label %cond.false
83
84cond.true:                                        ; preds = %entry
85  br label %cond.end
86
87cond.false:                                       ; preds = %entry
88  br label %cond.end
89
90cond.end:                                         ; preds = %cond.false, %cond.true
91  %cond = phi i32 [ %f, %cond.true ], [ %t, %cond.false ]
92  ret i32 %cond
93}
94
95define i64 @test_i64(i32 %a, i64 %f, i64 %t) {
96; ALL-LABEL: test_i64:
97; ALL:       # %bb.0: # %entry
98; ALL-NEXT:    movq %rsi, %rax
99; ALL-NEXT:    xorl %ecx, %ecx
100; ALL-NEXT:    cmpl %ecx, %edi
101; ALL-NEXT:    setg %cl
102; ALL-NEXT:    testb $1, %cl
103; ALL-NEXT:    je .LBB3_1
104; ALL-NEXT:  # %bb.2: # %cond.end
105; ALL-NEXT:    retq
106; ALL-NEXT:  .LBB3_1: # %cond.false
107; ALL-NEXT:    movq %rdx, %rax
108; ALL-NEXT:    retq
109entry:
110  %cmp = icmp sgt i32 %a, 0
111  br i1 %cmp, label %cond.true, label %cond.false
112
113cond.true:                                        ; preds = %entry
114  br label %cond.end
115
116cond.false:                                       ; preds = %entry
117  br label %cond.end
118
119cond.end:                                         ; preds = %cond.false, %cond.true
120  %cond = phi i64 [ %f, %cond.true ], [ %t, %cond.false ]
121  ret i64 %cond
122}
123
124define float @test_float(i32 %a, float %f, float %t) {
125; ALL-LABEL: test_float:
126; ALL:       # %bb.0: # %entry
127; ALL-NEXT:    xorl %eax, %eax
128; ALL-NEXT:    cmpl %eax, %edi
129; ALL-NEXT:    setg %al
130; ALL-NEXT:    testb $1, %al
131; ALL-NEXT:    je .LBB4_1
132; ALL-NEXT:  # %bb.2: # %cond.end
133; ALL-NEXT:    retq
134; ALL-NEXT:  .LBB4_1: # %cond.false
135; ALL-NEXT:    movaps %xmm1, %xmm0
136; ALL-NEXT:    retq
137entry:
138  %cmp = icmp sgt i32 %a, 0
139  br i1 %cmp, label %cond.true, label %cond.false
140
141cond.true:                                        ; preds = %entry
142  br label %cond.end
143
144cond.false:                                       ; preds = %entry
145  br label %cond.end
146
147cond.end:                                         ; preds = %cond.false, %cond.true
148  %cond = phi float [ %f, %cond.true ], [ %t, %cond.false ]
149  ret float %cond
150}
151
152define double @test_double(i32 %a, double %f, double %t) {
153; ALL-LABEL: test_double:
154; ALL:       # %bb.0: # %entry
155; ALL-NEXT:    xorl %eax, %eax
156; ALL-NEXT:    cmpl %eax, %edi
157; ALL-NEXT:    setg %al
158; ALL-NEXT:    testb $1, %al
159; ALL-NEXT:    je .LBB5_1
160; ALL-NEXT:  # %bb.2: # %cond.end
161; ALL-NEXT:    retq
162; ALL-NEXT:  .LBB5_1: # %cond.false
163; ALL-NEXT:    movaps %xmm1, %xmm0
164; ALL-NEXT:    retq
165entry:
166  %cmp = icmp sgt i32 %a, 0
167  br i1 %cmp, label %cond.true, label %cond.false
168
169cond.true:                                        ; preds = %entry
170  br label %cond.end
171
172cond.false:                                       ; preds = %entry
173  br label %cond.end
174
175cond.end:                                         ; preds = %cond.false, %cond.true
176  %cond = phi double [ %f, %cond.true ], [ %t, %cond.false ]
177  ret double %cond
178}
179