1 ; RUN: llc -mtriple arm-unknown -mattr=+vfp2,+v6 -global-isel %s -o - | FileCheck %s
3 define void @test_void_return() {
4 ; CHECK-LABEL: test_void_return:
10 define i32 @test_constant_return_i32() {
11 ; CHECK-LABEL: test_constant_return_i32:
18 define zeroext i1 @test_zext_i1(i1 %x) {
19 ; CHECK-LABEL: test_zext_i1
20 ; CHECK: and r0, r0, #1
26 define signext i1 @test_sext_i1(i1 %x) {
27 ; CHECK-LABEL: test_sext_i1
29 ; CHECK: lsl r0, r0, r1
30 ; CHECK: asr r0, r0, r1
36 define zeroext i8 @test_ext_i8(i8 %x) {
37 ; CHECK-LABEL: test_ext_i8:
45 define signext i16 @test_ext_i16(i16 %x) {
46 ; CHECK-LABEL: test_ext_i16:
48 ; CHECK: lsl r0, r0, r1
49 ; CHECK: asr r0, r0, r1
55 define void @test_trunc_i32_i16(i32 %v, ptr %p) {
56 ; CHECK-LABEL: test_trunc_i32_i16:
57 ; The trunc doesn't result in any instructions, but we
58 ; expect the store to be explicitly 16-bit.
59 ; CHECK: strh r0, [r1]
62 %v16 = trunc i32 %v to i16
63 store i16 %v16, ptr %p
67 define void @test_trunc_i32_i8(i32 %v, ptr %p) {
68 ; CHECK-LABEL: test_trunc_i32_i8:
69 ; The trunc doesn't result in any instructions, but we
70 ; expect the store to be explicitly 8-bit.
71 ; CHECK: strb r0, [r1]
74 %v8 = trunc i32 %v to i8
79 define i8 @test_add_i8(i8 %x, i8 %y) {
80 ; CHECK-LABEL: test_add_i8:
81 ; CHECK: add r0, r0, r1
88 define i16 @test_add_i16(i16 %x, i16 %y) {
89 ; CHECK-LABEL: test_add_i16:
90 ; CHECK: add r0, r0, r1
97 define i32 @test_add_i32(i32 %x, i32 %y) {
98 ; CHECK-LABEL: test_add_i32:
99 ; CHECK: add r0, r0, r1
102 %sum = add i32 %x, %y
106 define i8 @test_sub_i8(i8 %x, i8 %y) {
107 ; CHECK-LABEL: test_sub_i8:
108 ; CHECK: sub r0, r0, r1
115 define i16 @test_sub_i16(i16 %x, i16 %y) {
116 ; CHECK-LABEL: test_sub_i16:
117 ; CHECK: sub r0, r0, r1
120 %sum = sub i16 %x, %y
124 define i32 @test_sub_i32(i32 %x, i32 %y) {
125 ; CHECK-LABEL: test_sub_i32:
126 ; CHECK: sub r0, r0, r1
129 %sum = sub i32 %x, %y
133 define i8 @test_mul_i8(i8 %x, i8 %y) {
134 ; CHECK-LABEL: test_mul_i8:
135 ; CHECK: mul r0, r0, r1
142 define i16 @test_mul_i16(i16 %x, i16 %y) {
143 ; CHECK-LABEL: test_mul_i16:
144 ; CHECK: mul r0, r0, r1
147 %sum = mul i16 %x, %y
151 define i32 @test_mul_i32(i32 %x, i32 %y) {
152 ; CHECK-LABEL: test_mul_i32:
153 ; CHECK: mul r0, r0, r1
156 %sum = mul i32 %x, %y
160 define i8 @test_and_i8(i8 %x, i8 %y) {
161 ; CHECK-LABEL: test_and_i8:
162 ; CHECK: and r0, r0, r1
169 define i16 @test_and_i16(i16 %x, i16 %y) {
170 ; CHECK-LABEL: test_and_i16:
171 ; CHECK: and r0, r0, r1
174 %sum = and i16 %x, %y
178 define i32 @test_and_i32(i32 %x, i32 %y) {
179 ; CHECK-LABEL: test_and_i32:
180 ; CHECK: and r0, r0, r1
183 %sum = and i32 %x, %y
187 define i8 @test_or_i8(i8 %x, i8 %y) {
188 ; CHECK-LABEL: test_or_i8:
189 ; CHECK: orr r0, r0, r1
196 define i16 @test_or_i16(i16 %x, i16 %y) {
197 ; CHECK-LABEL: test_or_i16:
198 ; CHECK: orr r0, r0, r1
205 define i32 @test_or_i32(i32 %x, i32 %y) {
206 ; CHECK-LABEL: test_or_i32:
207 ; CHECK: orr r0, r0, r1
214 define i8 @test_xor_i8(i8 %x, i8 %y) {
215 ; CHECK-LABEL: test_xor_i8:
216 ; CHECK: eor r0, r0, r1
223 define i16 @test_xor_i16(i16 %x, i16 %y) {
224 ; CHECK-LABEL: test_xor_i16:
225 ; CHECK: eor r0, r0, r1
228 %sum = xor i16 %x, %y
232 define i32 @test_xor_i32(i32 %x, i32 %y) {
233 ; CHECK-LABEL: test_xor_i32:
234 ; CHECK: eor r0, r0, r1
237 %sum = xor i32 %x, %y
241 define i32 @test_stack_args_i32(i32 %p0, i32 %p1, i32 %p2, i32 %p3, i32 %p4, i32 %p5) {
242 ; CHECK-LABEL: test_stack_args_i32:
243 ; CHECK: add [[P5ADDR:r[0-9]+]], sp, #4
244 ; CHECK: ldr [[P5:r[0-9]+]], {{.*}}[[P5ADDR]]
245 ; CHECK: add r0, r2, [[P5]]
248 %sum = add i32 %p2, %p5
252 define i16 @test_stack_args_mixed(i32 %p0, i16 %p1, i8 %p2, i1 %p3, i8 %p4, i16 %p5) {
253 ; CHECK-LABEL: test_stack_args_mixed:
254 ; CHECK: add [[P5ADDR:r[0-9]+]], sp, #4
255 ; CHECK: ldr [[P5:r[0-9]+]], {{.*}}[[P5ADDR]]
256 ; CHECK: add r0, r1, [[P5]]
259 %sum = add i16 %p1, %p5
263 define i16 @test_stack_args_zeroext(i32 %p0, i16 %p1, i8 %p2, i1 %p3, i16 zeroext %p4) {
264 ; CHECK-LABEL: test_stack_args_zeroext:
265 ; CHECK: mov [[P4ADDR:r[0-9]+]], sp
266 ; CHECK: ldr [[P4:r[0-9]+]], {{.*}}[[P4ADDR]]
267 ; CHECK: add r0, r1, [[P4]]
270 %sum = add i16 %p1, %p4
274 define i8 @test_stack_args_signext(i32 %p0, i16 %p1, i8 %p2, i1 %p3, i8 signext %p4) {
275 ; CHECK-LABEL: test_stack_args_signext:
276 ; CHECK: mov [[P4ADDR:r[0-9]+]], sp
277 ; CHECK: ldr [[P4:r[0-9]+]], {{.*}}[[P4ADDR]]
278 ; CHECK: add r0, r2, [[P4]]
281 %sum = add i8 %p2, %p4
285 define i8 @test_stack_args_noext(i32 %p0, i16 %p1, i8 %p2, i1 %p3, i8 %p4) {
286 ; CHECK-LABEL: test_stack_args_noext:
287 ; CHECK: mov [[P4ADDR:r[0-9]+]], sp
288 ; CHECK: ldr [[P4:r[0-9]+]], {{.*}}[[P4ADDR]]
289 ; CHECK: add r0, r2, [[P4]]
292 %sum = add i8 %p2, %p4
296 define i32 @test_ptr_arg_in_reg(ptr %p) {
297 ; CHECK-LABEL: test_ptr_arg_in_reg:
298 ; CHECK: ldr r0, [r0]
301 %v = load i32, ptr %p
305 define i32 @test_ptr_arg_on_stack(i32 %f0, i32 %f1, i32 %f2, i32 %f3, ptr %p) {
306 ; CHECK-LABEL: test_ptr_arg_on_stack:
308 ; CHECK: ldr r0, [r0]
309 ; CHECK: ldr r0, [r0]
312 %v = load i32, ptr %p
316 define ptr @test_ptr_ret(ptr %p) {
317 ; CHECK-LABEL: test_ptr_ret:
318 ; CHECK: ldr r0, [r0]
321 %v = load ptr, ptr %p
325 define arm_aapcs_vfpcc float @test_float_hard(float %f0, float %f1) {
326 ; CHECK-LABEL: test_float_hard:
327 ; CHECK: vadd.f32 s0, s0, s1
330 %v = fadd float %f0, %f1
334 define arm_aapcscc float @test_float_softfp(float %f0, float %f1) {
335 ; CHECK-LABEL: test_float_softfp:
336 ; CHECK-DAG: vmov [[F0:s[0-9]+]], r0
337 ; CHECK-DAG: vmov [[F1:s[0-9]+]], r1
338 ; CHECK: vadd.f32 [[FV:s[0-9]+]], [[F0]], [[F1]]
339 ; CHECK: vmov r0, [[FV]]
342 %v = fadd float %f0, %f1
346 define arm_aapcs_vfpcc double @test_double_hard(double %f0, double %f1) {
347 ; CHECK-LABEL: test_double_hard:
348 ; CHECK: vadd.f64 d0, d0, d1
351 %v = fadd double %f0, %f1
355 define arm_aapcscc double @test_double_softfp(double %f0, double %f1) {
356 ; CHECK-LABEL: test_double_softfp:
357 ; CHECK-DAG: vmov [[F0:d[0-9]+]], r0, r1
358 ; CHECK-DAG: vmov [[F1:d[0-9]+]], r2, r3
359 ; CHECK: vadd.f64 [[FV:d[0-9]+]], [[F0]], [[F1]]
360 ; CHECK: vmov r0, r1, [[FV]]
363 %v = fadd double %f0, %f1
367 define arm_aapcscc i32 @test_cmp_i32_eq(i32 %a, i32 %b) {
368 ; CHECK-LABEL: test_cmp_i32_eq:
369 ; CHECK: mov [[V:r[0-9]+]], #0
371 ; CHECK: moveq [[V]], #1
372 ; CHECK: and r0, [[V]], #1
375 %v = icmp eq i32 %a, %b
376 %r = zext i1 %v to i32
380 define arm_aapcscc i32 @test_cmp_ptr_neq(ptr %a, ptr %b) {
381 ; CHECK-LABEL: test_cmp_ptr_neq:
382 ; CHECK: mov [[V:r[0-9]+]], #0
384 ; CHECK: movne [[V]], #1
385 ; CHECK: and r0, [[V]], #1
388 %v = icmp ne ptr %a, %b
389 %r = zext i1 %v to i32
393 define arm_aapcscc i32 @test_cmp_i16_slt(i16 %a, i16 %b) {
394 ; CHECK-LABEL: test_cmp_i16_slt:
395 ; CHECK-DAG: mov [[V:r[0-9]+]], #0
397 ; CHECK: movlt [[V]], #1
398 ; CHECK: and r0, [[V]], #1
401 %v = icmp slt i16 %a, %b
402 %r = zext i1 %v to i32
406 define arm_aapcscc i32 @test_select_i32(i32 %a, i32 %b, i1 %cond) {
407 ; CHECK-LABEL: test_select_i32
409 ; CHECK: moveq r0, r1
412 %r = select i1 %cond, i32 %a, i32 %b
416 define arm_aapcscc ptr @test_select_ptr(ptr %a, ptr %b, i1 %cond) {
417 ; CHECK-LABEL: test_select_ptr
419 ; CHECK: moveq r0, r1
422 %r = select i1 %cond, ptr %a, ptr %b
426 define arm_aapcscc void @test_br() {
427 ; CHECK-LABEL: test_br
428 ; CHECK: [[LABEL:.L[[:alnum:]_]+]]:
437 declare arm_aapcscc void @brcond1()
438 declare arm_aapcscc void @brcond2()
440 define arm_aapcscc void @test_brcond(i32 %n) {
441 ; CHECK-LABEL: test_brcond
443 ; CHECK-NEXT: movgt [[RCMP:r[0-9]+]], #1
444 ; CHECK: tst [[RCMP]], #1
445 ; CHECK-NEXT: beq [[FALSE:.L[[:alnum:]_]+]]
450 %cmp = icmp sgt i32 %n, 0
451 br i1 %cmp, label %if.true, label %if.false
454 call arm_aapcscc void @brcond1()
458 call arm_aapcscc void @brcond2()