1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+f -target-abi=ilp32 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV32IF
5 ; Exercises the ILP32 calling convention code in the case that f32 is a legal
6 ; type. As well as testing that lowering is correct, these tests also aim to
7 ; check that floating point load/store or integer load/store is chosen
8 ; optimally when floats are passed on the stack.
10 define float @onstack_f32_noop(i64 %a, i64 %b, i64 %c, i64 %d, float %e, float %f) nounwind {
11 ; RV32IF-LABEL: onstack_f32_noop:
13 ; RV32IF-NEXT: lw a0, 4(sp)
18 define float @onstack_f32_fadd(i64 %a, i64 %b, i64 %c, i64 %d, float %e, float %f) nounwind {
19 ; RV32IF-LABEL: onstack_f32_fadd:
21 ; RV32IF-NEXT: flw fa5, 4(sp)
22 ; RV32IF-NEXT: flw fa4, 0(sp)
23 ; RV32IF-NEXT: fadd.s fa5, fa4, fa5
24 ; RV32IF-NEXT: fmv.x.w a0, fa5
26 %1 = fadd float %e, %f
30 define float @caller_onstack_f32_noop(float %a) nounwind {
31 ; RV32IF-LABEL: caller_onstack_f32_noop:
33 ; RV32IF-NEXT: addi sp, sp, -16
34 ; RV32IF-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
35 ; RV32IF-NEXT: sw a0, 4(sp)
36 ; RV32IF-NEXT: lui a1, 264704
37 ; RV32IF-NEXT: li a0, 1
38 ; RV32IF-NEXT: li a2, 2
39 ; RV32IF-NEXT: li a4, 3
40 ; RV32IF-NEXT: li a6, 4
41 ; RV32IF-NEXT: sw a1, 0(sp)
42 ; RV32IF-NEXT: li a1, 0
43 ; RV32IF-NEXT: li a3, 0
44 ; RV32IF-NEXT: li a5, 0
45 ; RV32IF-NEXT: li a7, 0
46 ; RV32IF-NEXT: call onstack_f32_noop
47 ; RV32IF-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
48 ; RV32IF-NEXT: addi sp, sp, 16
50 %1 = call float @onstack_f32_noop(i64 1, i64 2, i64 3, i64 4, float 5.0, float %a)
54 define float @caller_onstack_f32_fadd(float %a, float %b) nounwind {
55 ; RV32IF-LABEL: caller_onstack_f32_fadd:
57 ; RV32IF-NEXT: addi sp, sp, -16
58 ; RV32IF-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
59 ; RV32IF-NEXT: fmv.w.x fa5, a1
60 ; RV32IF-NEXT: fmv.w.x fa4, a0
61 ; RV32IF-NEXT: fadd.s fa3, fa4, fa5
62 ; RV32IF-NEXT: fsub.s fa5, fa5, fa4
63 ; RV32IF-NEXT: fsw fa5, 4(sp)
64 ; RV32IF-NEXT: li a0, 1
65 ; RV32IF-NEXT: li a2, 2
66 ; RV32IF-NEXT: li a4, 3
67 ; RV32IF-NEXT: li a6, 4
68 ; RV32IF-NEXT: fsw fa3, 0(sp)
69 ; RV32IF-NEXT: li a1, 0
70 ; RV32IF-NEXT: li a3, 0
71 ; RV32IF-NEXT: li a5, 0
72 ; RV32IF-NEXT: li a7, 0
73 ; RV32IF-NEXT: call onstack_f32_noop
74 ; RV32IF-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
75 ; RV32IF-NEXT: addi sp, sp, 16
77 %1 = fadd float %a, %b
78 %2 = fsub float %b, %a
79 %3 = call float @onstack_f32_noop(i64 1, i64 2, i64 3, i64 4, float %1, float %2)