1; Test conditional sibling calls.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5declare void @fun_a()
6declare void @fun_b()
7declare void @fun_c(i32)
8
9@var = global i32 1;
10
11; Check a conditional sibling call.
12define void @f1(i32 %val1, i32 %val2) {
13; CHECK-LABEL: f1:
14; CHECK: cr %r2, %r3
15; CHECK: jgl fun_a@PLT
16; CHECK: br %r14
17  %cond = icmp slt i32 %val1, %val2;
18  br i1 %cond, label %a, label %b;
19
20a:
21  tail call void @fun_a()
22  ret void
23
24b:
25  store i32 1, i32 *@var;
26  ret void
27}
28
29; Check a conditional sibling call when there are two possibilities.
30define void @f2(i32 %val1, i32 %val2) {
31; CHECK-LABEL: f2:
32; CHECK: cr %r2, %r3
33; CHECK: jghe fun_b@PLT
34; CHECK: jg fun_a@PLT
35  %cond = icmp slt i32 %val1, %val2;
36  br i1 %cond, label %a, label %b;
37
38a:
39  tail call void @fun_a()
40  ret void
41
42b:
43  tail call void @fun_b()
44  ret void
45}
46
47; Check a conditional sibling call with an argument - not supported.
48define void @f3(i32 %val1, i32 %val2) {
49; CHECK-LABEL: f3:
50; CHECK: crjhe %r2, %r3
51; CHECK: jg fun_c@PLT
52; CHECK: br %r14
53  %cond = icmp slt i32 %val1, %val2;
54  br i1 %cond, label %a, label %b;
55
56a:
57  tail call void @fun_c(i32 1)
58  ret void
59
60b:
61  store i32 1, i32 *@var;
62  ret void
63}
64
65; Check a conditional sibling call - unsigned compare.
66define void @f4(i32 %val1, i32 %val2) {
67; CHECK-LABEL: f4:
68; CHECK: clr %r2, %r3
69; CHECK: jgl fun_a@PLT
70; CHECK: br %r14
71  %cond = icmp ult i32 %val1, %val2;
72  br i1 %cond, label %a, label %b;
73
74a:
75  tail call void @fun_a()
76  ret void
77
78b:
79  store i32 1, i32 *@var;
80  ret void
81}
82
83; Check a conditional sibling call - 64-bit compare.
84define void @f5(i64 %val1, i64 %val2) {
85; CHECK-LABEL: f5:
86; CHECK: cgr %r2, %r3
87; CHECK: jgl fun_a@PLT
88; CHECK: br %r14
89  %cond = icmp slt i64 %val1, %val2;
90  br i1 %cond, label %a, label %b;
91
92a:
93  tail call void @fun_a()
94  ret void
95
96b:
97  store i32 1, i32 *@var;
98  ret void
99}
100
101; Check a conditional sibling call - unsigned 64-bit compare.
102define void @f6(i64 %val1, i64 %val2) {
103; CHECK-LABEL: f6:
104; CHECK: clgr %r2, %r3
105; CHECK: jgl fun_a@PLT
106; CHECK: br %r14
107  %cond = icmp ult i64 %val1, %val2;
108  br i1 %cond, label %a, label %b;
109
110a:
111  tail call void @fun_a()
112  ret void
113
114b:
115  store i32 1, i32 *@var;
116  ret void
117}
118
119; Check a conditional sibling call - less-equal compare.
120define void @f7(i32 %val1, i32 %val2) {
121; CHECK-LABEL: f7:
122; CHECK: cr %r2, %r3
123; CHECK: jgle fun_a@PLT
124; CHECK: br %r14
125  %cond = icmp sle i32 %val1, %val2;
126  br i1 %cond, label %a, label %b;
127
128a:
129  tail call void @fun_a()
130  ret void
131
132b:
133  store i32 1, i32 *@var;
134  ret void
135}
136
137; Check a conditional sibling call - high compare.
138define void @f8(i32 %val1, i32 %val2) {
139; CHECK-LABEL: f8:
140; CHECK: cr %r2, %r3
141; CHECK: jgh fun_a@PLT
142; CHECK: br %r14
143  %cond = icmp sgt i32 %val1, %val2;
144  br i1 %cond, label %a, label %b;
145
146a:
147  tail call void @fun_a()
148  ret void
149
150b:
151  store i32 1, i32 *@var;
152  ret void
153}
154
155; Check a conditional sibling call - high-equal compare.
156define void @f9(i32 %val1, i32 %val2) {
157; CHECK-LABEL: f9:
158; CHECK: cr %r2, %r3
159; CHECK: jghe fun_a@PLT
160; CHECK: br %r14
161  %cond = icmp sge i32 %val1, %val2;
162  br i1 %cond, label %a, label %b;
163
164a:
165  tail call void @fun_a()
166  ret void
167
168b:
169  store i32 1, i32 *@var;
170  ret void
171}
172
173; Check a conditional sibling call - equal compare.
174define void @f10(i32 %val1, i32 %val2) {
175; CHECK-LABEL: f10:
176; CHECK: cr %r2, %r3
177; CHECK: jge fun_a@PLT
178; CHECK: br %r14
179  %cond = icmp eq i32 %val1, %val2;
180  br i1 %cond, label %a, label %b;
181
182a:
183  tail call void @fun_a()
184  ret void
185
186b:
187  store i32 1, i32 *@var;
188  ret void
189}
190
191; Check a conditional sibling call - unequal compare.
192define void @f11(i32 %val1, i32 %val2) {
193; CHECK-LABEL: f11:
194; CHECK: cr %r2, %r3
195; CHECK: jglh fun_a@PLT
196; CHECK: br %r14
197  %cond = icmp ne i32 %val1, %val2;
198  br i1 %cond, label %a, label %b;
199
200a:
201  tail call void @fun_a()
202  ret void
203
204b:
205  store i32 1, i32 *@var;
206  ret void
207}
208
209; Check a conditional sibling call - immediate slt.
210define void @f12(i32 %val1) {
211; CHECK-LABEL: f12:
212; CHECK: chi %r2, 4
213; CHECK: jgle fun_a@PLT
214; CHECK: br %r14
215  %cond = icmp slt i32 %val1, 5;
216  br i1 %cond, label %a, label %b;
217
218a:
219  tail call void @fun_a()
220  ret void
221
222b:
223  store i32 1, i32 *@var;
224  ret void
225}
226
227; Check a conditional sibling call - immediate sle.
228define void @f13(i32 %val1) {
229; CHECK-LABEL: f13:
230; CHECK: chi %r2, 5
231; CHECK: jgle fun_a@PLT
232; CHECK: br %r14
233  %cond = icmp sle i32 %val1, 5;
234  br i1 %cond, label %a, label %b;
235
236a:
237  tail call void @fun_a()
238  ret void
239
240b:
241  store i32 1, i32 *@var;
242  ret void
243}
244
245; Check a conditional sibling call - immediate sgt.
246define void @f14(i32 %val1) {
247; CHECK-LABEL: f14:
248; CHECK: chi %r2, 6
249; CHECK: jghe fun_a@PLT
250; CHECK: br %r14
251  %cond = icmp sgt i32 %val1, 5;
252  br i1 %cond, label %a, label %b;
253
254a:
255  tail call void @fun_a()
256  ret void
257
258b:
259  store i32 1, i32 *@var;
260  ret void
261}
262
263; Check a conditional sibling call - immediate sge.
264define void @f15(i32 %val1) {
265; CHECK-LABEL: f15:
266; CHECK: chi %r2, 5
267; CHECK: jghe fun_a@PLT
268; CHECK: br %r14
269  %cond = icmp sge i32 %val1, 5;
270  br i1 %cond, label %a, label %b;
271
272a:
273  tail call void @fun_a()
274  ret void
275
276b:
277  store i32 1, i32 *@var;
278  ret void
279}
280
281; Check a conditional sibling call - immediate eq.
282define void @f16(i32 %val1) {
283; CHECK-LABEL: f16:
284; CHECK: chi %r2, 5
285; CHECK: jge fun_a@PLT
286; CHECK: br %r14
287  %cond = icmp eq i32 %val1, 5;
288  br i1 %cond, label %a, label %b;
289
290a:
291  tail call void @fun_a()
292  ret void
293
294b:
295  store i32 1, i32 *@var;
296  ret void
297}
298
299; Check a conditional sibling call - immediate ne.
300define void @f17(i32 %val1) {
301; CHECK-LABEL: f17:
302; CHECK: chi %r2, 5
303; CHECK: jglh fun_a@PLT
304; CHECK: br %r14
305  %cond = icmp ne i32 %val1, 5;
306  br i1 %cond, label %a, label %b;
307
308a:
309  tail call void @fun_a()
310  ret void
311
312b:
313  store i32 1, i32 *@var;
314  ret void
315}
316
317; Check a conditional sibling call - immediate ult.
318define void @f18(i32 %val1) {
319; CHECK-LABEL: f18:
320; CHECK: clfi %r2, 4
321; CHECK: jgle fun_a@PLT
322; CHECK: br %r14
323  %cond = icmp ult i32 %val1, 5;
324  br i1 %cond, label %a, label %b;
325
326a:
327  tail call void @fun_a()
328  ret void
329
330b:
331  store i32 1, i32 *@var;
332  ret void
333}
334
335; Check a conditional sibling call - immediate 64-bit slt.
336define void @f19(i64 %val1) {
337; CHECK-LABEL: f19:
338; CHECK: cghi %r2, 4
339; CHECK: jgle fun_a@PLT
340; CHECK: br %r14
341  %cond = icmp slt i64 %val1, 5;
342  br i1 %cond, label %a, label %b;
343
344a:
345  tail call void @fun_a()
346  ret void
347
348b:
349  store i32 1, i32 *@var;
350  ret void
351}
352
353; Check a conditional sibling call - immediate 64-bit ult.
354define void @f20(i64 %val1) {
355; CHECK-LABEL: f20:
356; CHECK: clgfi %r2, 4
357; CHECK: jgle fun_a@PLT
358; CHECK: br %r14
359  %cond = icmp ult i64 %val1, 5;
360  br i1 %cond, label %a, label %b;
361
362a:
363  tail call void @fun_a()
364  ret void
365
366b:
367  store i32 1, i32 *@var;
368  ret void
369}
370