1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-apple-darwin -aarch64-enable-collect-loh=false < %s | FileCheck %s --check-prefixes=CHECK,CHECK-SD
3 ; RUN: llc -mtriple=aarch64-apple-darwin -aarch64-enable-collect-loh=false -global-isel < %s | FileCheck %s --check-prefixes=CHECK,CHECK-GI
5 @board = common global [400 x i8] zeroinitializer, align 1
6 @next_string = common global i32 0, align 4
7 @string_number = common global [400 x i32] zeroinitializer, align 4
9 ; Function Attrs: nounwind ssp
10 define void @new_position(i32 %pos) {
11 ; CHECK-SD-LABEL: new_position:
12 ; CHECK-SD: ; %bb.0: ; %entry
13 ; CHECK-SD-NEXT: adrp x9, _board@GOTPAGE
14 ; CHECK-SD-NEXT: ; kill: def $w0 killed $w0 def $x0
15 ; CHECK-SD-NEXT: sxtw x8, w0
16 ; CHECK-SD-NEXT: ldr x9, [x9, _board@GOTPAGEOFF]
17 ; CHECK-SD-NEXT: ldrb w9, [x9, x8]
18 ; CHECK-SD-NEXT: sub w9, w9, #1
19 ; CHECK-SD-NEXT: cmp w9, #1
20 ; CHECK-SD-NEXT: b.hi LBB0_2
21 ; CHECK-SD-NEXT: ; %bb.1: ; %if.then
22 ; CHECK-SD-NEXT: adrp x9, _next_string@GOTPAGE
23 ; CHECK-SD-NEXT: adrp x10, _string_number@GOTPAGE
24 ; CHECK-SD-NEXT: ldr x9, [x9, _next_string@GOTPAGEOFF]
25 ; CHECK-SD-NEXT: ldr x10, [x10, _string_number@GOTPAGEOFF]
26 ; CHECK-SD-NEXT: ldr w9, [x9]
27 ; CHECK-SD-NEXT: str w9, [x10, x8, lsl #2]
28 ; CHECK-SD-NEXT: LBB0_2: ; %if.end
31 ; CHECK-GI-LABEL: new_position:
32 ; CHECK-GI: ; %bb.0: ; %entry
33 ; CHECK-GI-NEXT: adrp x8, _board@GOTPAGE
34 ; CHECK-GI-NEXT: ldr x8, [x8, _board@GOTPAGEOFF]
35 ; CHECK-GI-NEXT: ldrb w8, [x8, w0, sxtw]
36 ; CHECK-GI-NEXT: sub w8, w8, #1
37 ; CHECK-GI-NEXT: cmp w8, #2
38 ; CHECK-GI-NEXT: b.hs LBB0_2
39 ; CHECK-GI-NEXT: ; %bb.1: ; %if.then
40 ; CHECK-GI-NEXT: adrp x8, _next_string@GOTPAGE
41 ; CHECK-GI-NEXT: adrp x9, _string_number@GOTPAGE
42 ; CHECK-GI-NEXT: ldr x8, [x8, _next_string@GOTPAGEOFF]
43 ; CHECK-GI-NEXT: ldr x9, [x9, _string_number@GOTPAGEOFF]
44 ; CHECK-GI-NEXT: ldr w8, [x8]
45 ; CHECK-GI-NEXT: str w8, [x9, w0, sxtw #2]
46 ; CHECK-GI-NEXT: LBB0_2: ; %if.end
49 %idxprom = sext i32 %pos to i64
50 %arrayidx = getelementptr inbounds [400 x i8], ptr @board, i64 0, i64 %idxprom
51 %tmp = load i8, ptr %arrayidx, align 1
52 %.off = add i8 %tmp, -1
53 %switch = icmp ult i8 %.off, 2
54 br i1 %switch, label %if.then, label %if.end
56 if.then: ; preds = %entry
57 %tmp1 = load i32, ptr @next_string, align 4
58 %arrayidx8 = getelementptr inbounds [400 x i32], ptr @string_number, i64 0, i64 %idxprom
59 store i32 %tmp1, ptr %arrayidx8, align 4
62 if.end: ; preds = %if.then, %entry
66 define zeroext i1 @test8_0(i8 zeroext %x) align 2 {
67 ; CHECK-LABEL: test8_0:
68 ; CHECK: ; %bb.0: ; %entry
69 ; CHECK-NEXT: add w8, w0, #74
70 ; CHECK-NEXT: and w8, w8, #0xff
71 ; CHECK-NEXT: cmp w8, #236
72 ; CHECK-NEXT: cset w0, lo
76 %1 = icmp ult i8 %0, -20
77 br i1 %1, label %ret_true, label %ret_false
84 define zeroext i1 @test8_1(i8 zeroext %x) align 2 {
85 ; CHECK-SD-LABEL: test8_1:
86 ; CHECK-SD: ; %bb.0: ; %entry
87 ; CHECK-SD-NEXT: sub w8, w0, #10
88 ; CHECK-SD-NEXT: cmp w8, #89
89 ; CHECK-SD-NEXT: cset w0, hi
92 ; CHECK-GI-LABEL: test8_1:
93 ; CHECK-GI: ; %bb.0: ; %entry
94 ; CHECK-GI-NEXT: sub w8, w0, #10
95 ; CHECK-GI-NEXT: cmp w8, #90
96 ; CHECK-GI-NEXT: cset w0, hs
100 %1 = icmp uge i8 %0, 90
101 br i1 %1, label %ret_true, label %ret_false
108 define zeroext i1 @test8_2(i8 zeroext %x) align 2 {
109 ; CHECK-SD-LABEL: test8_2:
110 ; CHECK-SD: ; %bb.0: ; %entry
111 ; CHECK-SD-NEXT: cmp w0, #208
112 ; CHECK-SD-NEXT: cset w0, ne
115 ; CHECK-GI-LABEL: test8_2:
116 ; CHECK-GI: ; %bb.0: ; %entry
117 ; CHECK-GI-NEXT: sub w8, w0, #29
118 ; CHECK-GI-NEXT: and w8, w8, #0xff
119 ; CHECK-GI-NEXT: cmp w8, #179
120 ; CHECK-GI-NEXT: cset w0, ne
124 %1 = icmp ne i8 %0, 179
125 br i1 %1, label %ret_true, label %ret_false
132 define zeroext i1 @test8_3(i8 zeroext %x) align 2 {
133 ; CHECK-SD-LABEL: test8_3:
134 ; CHECK-SD: ; %bb.0: ; %entry
135 ; CHECK-SD-NEXT: cmp w0, #209
136 ; CHECK-SD-NEXT: cset w0, eq
139 ; CHECK-GI-LABEL: test8_3:
140 ; CHECK-GI: ; %bb.0: ; %entry
141 ; CHECK-GI-NEXT: sub w8, w0, #55
142 ; CHECK-GI-NEXT: and w8, w8, #0xff
143 ; CHECK-GI-NEXT: cmp w8, #154
144 ; CHECK-GI-NEXT: cset w0, eq
148 %1 = icmp eq i8 %0, 154
149 br i1 %1, label %ret_true, label %ret_false
156 define zeroext i1 @test8_4(i8 zeroext %x) align 2 {
157 ; CHECK-SD-LABEL: test8_4:
158 ; CHECK-SD: ; %bb.0: ; %entry
159 ; CHECK-SD-NEXT: cmp w0, #39
160 ; CHECK-SD-NEXT: cset w0, ne
163 ; CHECK-GI-LABEL: test8_4:
164 ; CHECK-GI: ; %bb.0: ; %entry
165 ; CHECK-GI-NEXT: sub w8, w0, #79
166 ; CHECK-GI-NEXT: and w8, w8, #0xff
167 ; CHECK-GI-NEXT: cmp w8, #216
168 ; CHECK-GI-NEXT: cset w0, ne
172 %1 = icmp ne i8 %0, -40
173 br i1 %1, label %ret_true, label %ret_false
180 define zeroext i1 @test8_5(i8 zeroext %x) align 2 {
181 ; CHECK-SD-LABEL: test8_5:
182 ; CHECK-SD: ; %bb.0: ; %entry
183 ; CHECK-SD-NEXT: sub w8, w0, #123
184 ; CHECK-SD-NEXT: cmn w8, #106
185 ; CHECK-SD-NEXT: cset w0, hi
188 ; CHECK-GI-LABEL: test8_5:
189 ; CHECK-GI: ; %bb.0: ; %entry
190 ; CHECK-GI-NEXT: sub w8, w0, #123
191 ; CHECK-GI-NEXT: cmn w8, #105
192 ; CHECK-GI-NEXT: cset w0, hs
196 %1 = icmp uge i8 %0, -105
197 br i1 %1, label %ret_true, label %ret_false
204 define zeroext i1 @test8_6(i8 zeroext %x) align 2 {
205 ; CHECK-SD-LABEL: test8_6:
206 ; CHECK-SD: ; %bb.0: ; %entry
207 ; CHECK-SD-NEXT: sub w8, w0, #58
208 ; CHECK-SD-NEXT: cmp w8, #154
209 ; CHECK-SD-NEXT: cset w0, hi
212 ; CHECK-GI-LABEL: test8_6:
213 ; CHECK-GI: ; %bb.0: ; %entry
214 ; CHECK-GI-NEXT: sub w8, w0, #58
215 ; CHECK-GI-NEXT: cmp w8, #155
216 ; CHECK-GI-NEXT: cset w0, hs
220 %1 = icmp uge i8 %0, 155
221 br i1 %1, label %ret_true, label %ret_false
228 define zeroext i1 @test8_7(i8 zeroext %x) align 2 {
229 ; CHECK-LABEL: test8_7:
230 ; CHECK: ; %bb.0: ; %entry
231 ; CHECK-NEXT: sub w8, w0, #31
232 ; CHECK-NEXT: cmp w8, #124
233 ; CHECK-NEXT: cset w0, lo
237 %1 = icmp ult i8 %0, 124
238 br i1 %1, label %ret_true, label %ret_false
247 define zeroext i1 @test8_8(i8 zeroext %x) align 2 {
248 ; CHECK-SD-LABEL: test8_8:
249 ; CHECK-SD: ; %bb.0: ; %entry
250 ; CHECK-SD-NEXT: cmp w0, #66
251 ; CHECK-SD-NEXT: cset w0, ne
254 ; CHECK-GI-LABEL: test8_8:
255 ; CHECK-GI: ; %bb.0: ; %entry
256 ; CHECK-GI-NEXT: sub w8, w0, #66
257 ; CHECK-GI-NEXT: cmp w8, #1
258 ; CHECK-GI-NEXT: cset w0, hs
262 %1 = icmp uge i8 %0, 1
263 br i1 %1, label %ret_true, label %ret_false
270 define zeroext i1 @test16_0(i16 zeroext %x) align 2 {
271 ; CHECK-SD-LABEL: test16_0:
272 ; CHECK-SD: ; %bb.0: ; %entry
273 ; CHECK-SD-NEXT: mov w8, #5086 ; =0x13de
274 ; CHECK-SD-NEXT: cmp w0, w8
275 ; CHECK-SD-NEXT: cset w0, ne
278 ; CHECK-GI-LABEL: test16_0:
279 ; CHECK-GI: ; %bb.0: ; %entry
280 ; CHECK-GI-NEXT: mov w8, #18547 ; =0x4873
281 ; CHECK-GI-NEXT: mov w9, #23633 ; =0x5c51
282 ; CHECK-GI-NEXT: add w8, w0, w8
283 ; CHECK-GI-NEXT: cmp w9, w8, uxth
284 ; CHECK-GI-NEXT: cset w0, ne
287 %0 = add i16 %x, -46989
288 %1 = icmp ne i16 %0, -41903
289 br i1 %1, label %ret_true, label %ret_false
296 define zeroext i1 @test16_2(i16 zeroext %x) align 2 {
297 ; CHECK-SD-LABEL: test16_2:
298 ; CHECK-SD: ; %bb.0: ; %entry
299 ; CHECK-SD-NEXT: mov w8, #16882 ; =0x41f2
300 ; CHECK-SD-NEXT: mov w9, #40700 ; =0x9efc
301 ; CHECK-SD-NEXT: add w8, w0, w8
302 ; CHECK-SD-NEXT: cmp w9, w8, uxth
303 ; CHECK-SD-NEXT: cset w0, hi
306 ; CHECK-GI-LABEL: test16_2:
307 ; CHECK-GI: ; %bb.0: ; %entry
308 ; CHECK-GI-NEXT: mov w8, #16882 ; =0x41f2
309 ; CHECK-GI-NEXT: mov w9, #40699 ; =0x9efb
310 ; CHECK-GI-NEXT: add w8, w0, w8
311 ; CHECK-GI-NEXT: cmp w9, w8, uxth
312 ; CHECK-GI-NEXT: cset w0, hs
315 %0 = add i16 %x, 16882
316 %1 = icmp ule i16 %0, -24837
317 br i1 %1, label %ret_true, label %ret_false
324 define zeroext i1 @test16_3(i16 zeroext %x) align 2 {
325 ; CHECK-SD-LABEL: test16_3:
326 ; CHECK-SD: ; %bb.0: ; %entry
327 ; CHECK-SD-NEXT: mov w8, #53200 ; =0xcfd0
328 ; CHECK-SD-NEXT: cmp w0, w8
329 ; CHECK-SD-NEXT: cset w0, ne
332 ; CHECK-GI-LABEL: test16_3:
333 ; CHECK-GI: ; %bb.0: ; %entry
334 ; CHECK-GI-NEXT: mov w8, #29283 ; =0x7263
335 ; CHECK-GI-NEXT: mov w9, #16947 ; =0x4233
336 ; CHECK-GI-NEXT: add w8, w0, w8
337 ; CHECK-GI-NEXT: cmp w9, w8, uxth
338 ; CHECK-GI-NEXT: cset w0, ne
341 %0 = add i16 %x, 29283
342 %1 = icmp ne i16 %0, 16947
343 br i1 %1, label %ret_true, label %ret_false
350 define zeroext i1 @test16_4(i16 zeroext %x) align 2 {
351 ; CHECK-SD-LABEL: test16_4:
352 ; CHECK-SD: ; %bb.0: ; %entry
353 ; CHECK-SD-NEXT: mov w8, #29985 ; =0x7521
354 ; CHECK-SD-NEXT: mov w9, #15676 ; =0x3d3c
355 ; CHECK-SD-NEXT: add w8, w0, w8
356 ; CHECK-SD-NEXT: cmp w9, w8, uxth
357 ; CHECK-SD-NEXT: cset w0, lo
360 ; CHECK-GI-LABEL: test16_4:
361 ; CHECK-GI: ; %bb.0: ; %entry
362 ; CHECK-GI-NEXT: mov w8, #29985 ; =0x7521
363 ; CHECK-GI-NEXT: mov w9, #15677 ; =0x3d3d
364 ; CHECK-GI-NEXT: add w8, w0, w8
365 ; CHECK-GI-NEXT: cmp w9, w8, uxth
366 ; CHECK-GI-NEXT: cset w0, ls
369 %0 = add i16 %x, -35551
370 %1 = icmp uge i16 %0, 15677
371 br i1 %1, label %ret_true, label %ret_false
378 define zeroext i1 @test16_5(i16 zeroext %x) align 2 {
379 ; CHECK-SD-LABEL: test16_5:
380 ; CHECK-SD: ; %bb.0: ; %entry
381 ; CHECK-SD-NEXT: mov w8, #23282 ; =0x5af2
382 ; CHECK-SD-NEXT: cmp w0, w8
383 ; CHECK-SD-NEXT: cset w0, ne
386 ; CHECK-GI-LABEL: test16_5:
387 ; CHECK-GI: ; %bb.0: ; %entry
388 ; CHECK-GI-NEXT: mov w8, #-25214 ; =0xffff9d82
389 ; CHECK-GI-NEXT: mov w9, #63604 ; =0xf874
390 ; CHECK-GI-NEXT: add w8, w0, w8
391 ; CHECK-GI-NEXT: cmp w9, w8, uxth
392 ; CHECK-GI-NEXT: cset w0, ne
395 %0 = add i16 %x, -25214
396 %1 = icmp ne i16 %0, -1932
397 br i1 %1, label %ret_true, label %ret_false
404 define zeroext i1 @test16_6(i16 zeroext %x) align 2 {
405 ; CHECK-SD-LABEL: test16_6:
406 ; CHECK-SD: ; %bb.0: ; %entry
407 ; CHECK-SD-NEXT: mov w8, #-32194 ; =0xffff823e
408 ; CHECK-SD-NEXT: mov w9, #24320 ; =0x5f00
409 ; CHECK-SD-NEXT: add w8, w0, w8
410 ; CHECK-SD-NEXT: cmp w8, w9
411 ; CHECK-SD-NEXT: cset w0, hi
414 ; CHECK-GI-LABEL: test16_6:
415 ; CHECK-GI: ; %bb.0: ; %entry
416 ; CHECK-GI-NEXT: mov w8, #-32194 ; =0xffff823e
417 ; CHECK-GI-NEXT: mov w9, #24321 ; =0x5f01
418 ; CHECK-GI-NEXT: add w8, w0, w8
419 ; CHECK-GI-NEXT: cmp w8, w9
420 ; CHECK-GI-NEXT: cset w0, hs
423 %0 = add i16 %x, -32194
424 %1 = icmp uge i16 %0, -41215
425 br i1 %1, label %ret_true, label %ret_false
432 define zeroext i1 @test16_7(i16 zeroext %x) align 2 {
433 ; CHECK-SD-LABEL: test16_7:
434 ; CHECK-SD: ; %bb.0: ; %entry
435 ; CHECK-SD-NEXT: mov w8, #9272 ; =0x2438
436 ; CHECK-SD-NEXT: mov w9, #22619 ; =0x585b
437 ; CHECK-SD-NEXT: add w8, w0, w8
438 ; CHECK-SD-NEXT: cmp w9, w8, uxth
439 ; CHECK-SD-NEXT: cset w0, lo
442 ; CHECK-GI-LABEL: test16_7:
443 ; CHECK-GI: ; %bb.0: ; %entry
444 ; CHECK-GI-NEXT: mov w8, #9272 ; =0x2438
445 ; CHECK-GI-NEXT: mov w9, #22620 ; =0x585c
446 ; CHECK-GI-NEXT: add w8, w0, w8
447 ; CHECK-GI-NEXT: cmp w9, w8, uxth
448 ; CHECK-GI-NEXT: cset w0, ls
451 %0 = add i16 %x, 9272
452 %1 = icmp uge i16 %0, -42916
453 br i1 %1, label %ret_true, label %ret_false
460 define zeroext i1 @test16_8(i16 zeroext %x) align 2 {
461 ; CHECK-SD-LABEL: test16_8:
462 ; CHECK-SD: ; %bb.0: ; %entry
463 ; CHECK-SD-NEXT: mov w8, #4919 ; =0x1337
464 ; CHECK-SD-NEXT: cmp w0, w8
465 ; CHECK-SD-NEXT: cset w0, ne
468 ; CHECK-GI-LABEL: test16_8:
469 ; CHECK-GI: ; %bb.0: ; %entry
470 ; CHECK-GI-NEXT: mov w8, #6706 ; =0x1a32
471 ; CHECK-GI-NEXT: add w9, w0, #1787
472 ; CHECK-GI-NEXT: cmp w8, w9, uxth
473 ; CHECK-GI-NEXT: cset w0, ne
476 %0 = add i16 %x, -63749
477 %1 = icmp ne i16 %0, 6706
478 br i1 %1, label %ret_true, label %ret_false
485 define i64 @pr58109(i8 signext %0) {
486 ; CHECK-SD-LABEL: pr58109:
488 ; CHECK-SD-NEXT: add w8, w0, #1
489 ; CHECK-SD-NEXT: and w8, w8, #0xff
490 ; CHECK-SD-NEXT: subs w8, w8, #1
491 ; CHECK-SD-NEXT: csel w0, wzr, w8, lo
494 ; CHECK-GI-LABEL: pr58109:
496 ; CHECK-GI-NEXT: add w8, w0, #1
497 ; CHECK-GI-NEXT: and w8, w8, #0xff
498 ; CHECK-GI-NEXT: sub w8, w8, #1
499 ; CHECK-GI-NEXT: cmp w8, w8, uxtb
500 ; CHECK-GI-NEXT: csel w8, wzr, w8, ne
501 ; CHECK-GI-NEXT: and x0, x8, #0xff
504 %3 = call i8 @llvm.usub.sat.i8(i8 %2, i8 1)
505 %4 = zext i8 %3 to i64
509 define i64 @pr58109b(i8 signext %0, i64 %a, i64 %b) {
510 ; CHECK-SD-LABEL: pr58109b:
512 ; CHECK-SD-NEXT: add w8, w0, #1
513 ; CHECK-SD-NEXT: tst w8, #0xfe
514 ; CHECK-SD-NEXT: csel x0, x1, x2, eq
517 ; CHECK-GI-LABEL: pr58109b:
519 ; CHECK-GI-NEXT: add w8, w0, #1
520 ; CHECK-GI-NEXT: and w8, w8, #0xff
521 ; CHECK-GI-NEXT: cmp w8, #2
522 ; CHECK-GI-NEXT: csel x0, x1, x2, lo
525 %3 = icmp ult i8 %2, 2
526 %4 = select i1 %3, i64 %a, i64 %b
530 declare i8 @llvm.usub.sat.i8(i8, i8) #0