1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs -mattr=+f \
3 ; RUN: -target-abi ilp32f < %s \
4 ; RUN: | FileCheck -check-prefix=RV32-ILP32FD %s
5 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs -mattr=+d \
6 ; RUN: -target-abi ilp32d < %s \
7 ; RUN: | FileCheck -check-prefix=RV32-ILP32FD %s
9 ; This file contains tests that should have identical output for the ilp32f
12 define i32 @callee_float_in_fpr(i32 %a, float %b) nounwind {
13 ; RV32-ILP32FD-LABEL: callee_float_in_fpr:
14 ; RV32-ILP32FD: # %bb.0:
15 ; RV32-ILP32FD-NEXT: fcvt.w.s a1, fa0, rtz
16 ; RV32-ILP32FD-NEXT: add a0, a0, a1
17 ; RV32-ILP32FD-NEXT: ret
18 %b_fptosi = fptosi float %b to i32
19 %1 = add i32 %a, %b_fptosi
23 define i32 @caller_float_in_fpr() nounwind {
24 ; RV32-ILP32FD-LABEL: caller_float_in_fpr:
25 ; RV32-ILP32FD: # %bb.0:
26 ; RV32-ILP32FD-NEXT: addi sp, sp, -16
27 ; RV32-ILP32FD-NEXT: sw ra, 12(sp)
28 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI1_0)
29 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI1_0)
30 ; RV32-ILP32FD-NEXT: flw fa0, 0(a0)
31 ; RV32-ILP32FD-NEXT: addi a0, zero, 1
32 ; RV32-ILP32FD-NEXT: call callee_float_in_fpr
33 ; RV32-ILP32FD-NEXT: lw ra, 12(sp)
34 ; RV32-ILP32FD-NEXT: addi sp, sp, 16
35 ; RV32-ILP32FD-NEXT: ret
36 %1 = call i32 @callee_float_in_fpr(i32 1, float 2.0)
40 ; Must keep define on a single line due to an update_llc_test_checks.py limitation
41 define i32 @callee_float_in_fpr_exhausted_gprs(i64 %a, i64 %b, i64 %c, i64 %d, i32 %e, float %f) nounwind {
42 ; RV32-ILP32FD-LABEL: callee_float_in_fpr_exhausted_gprs:
43 ; RV32-ILP32FD: # %bb.0:
44 ; RV32-ILP32FD-NEXT: lw a0, 0(sp)
45 ; RV32-ILP32FD-NEXT: fcvt.w.s a1, fa0, rtz
46 ; RV32-ILP32FD-NEXT: add a0, a0, a1
47 ; RV32-ILP32FD-NEXT: ret
48 %f_fptosi = fptosi float %f to i32
49 %1 = add i32 %e, %f_fptosi
53 define i32 @caller_float_in_fpr_exhausted_gprs() nounwind {
54 ; RV32-ILP32FD-LABEL: caller_float_in_fpr_exhausted_gprs:
55 ; RV32-ILP32FD: # %bb.0:
56 ; RV32-ILP32FD-NEXT: addi sp, sp, -16
57 ; RV32-ILP32FD-NEXT: sw ra, 12(sp)
58 ; RV32-ILP32FD-NEXT: addi a1, zero, 5
59 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI3_0)
60 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI3_0)
61 ; RV32-ILP32FD-NEXT: flw fa0, 0(a0)
62 ; RV32-ILP32FD-NEXT: addi a0, zero, 1
63 ; RV32-ILP32FD-NEXT: addi a2, zero, 2
64 ; RV32-ILP32FD-NEXT: addi a4, zero, 3
65 ; RV32-ILP32FD-NEXT: addi a6, zero, 4
66 ; RV32-ILP32FD-NEXT: sw a1, 0(sp)
67 ; RV32-ILP32FD-NEXT: mv a1, zero
68 ; RV32-ILP32FD-NEXT: mv a3, zero
69 ; RV32-ILP32FD-NEXT: mv a5, zero
70 ; RV32-ILP32FD-NEXT: mv a7, zero
71 ; RV32-ILP32FD-NEXT: call callee_float_in_fpr_exhausted_gprs
72 ; RV32-ILP32FD-NEXT: lw ra, 12(sp)
73 ; RV32-ILP32FD-NEXT: addi sp, sp, 16
74 ; RV32-ILP32FD-NEXT: ret
75 %1 = call i32 @callee_float_in_fpr_exhausted_gprs(
76 i64 1, i64 2, i64 3, i64 4, i32 5, float 6.0)
80 ; Must keep define on a single line due to an update_llc_test_checks.py limitation
81 define i32 @callee_float_in_gpr_exhausted_fprs(float %a, float %b, float %c, float %d, float %e, float %f, float %g, float %h, float %i) nounwind {
82 ; RV32-ILP32FD-LABEL: callee_float_in_gpr_exhausted_fprs:
83 ; RV32-ILP32FD: # %bb.0:
84 ; RV32-ILP32FD-NEXT: fmv.w.x ft0, a0
85 ; RV32-ILP32FD-NEXT: fcvt.w.s a0, fa7, rtz
86 ; RV32-ILP32FD-NEXT: fcvt.w.s a1, ft0, rtz
87 ; RV32-ILP32FD-NEXT: add a0, a0, a1
88 ; RV32-ILP32FD-NEXT: ret
89 %h_fptosi = fptosi float %h to i32
90 %i_fptosi = fptosi float %i to i32
91 %1 = add i32 %h_fptosi, %i_fptosi
95 define i32 @caller_float_in_gpr_exhausted_fprs() nounwind {
96 ; RV32-ILP32FD-LABEL: caller_float_in_gpr_exhausted_fprs:
97 ; RV32-ILP32FD: # %bb.0:
98 ; RV32-ILP32FD-NEXT: addi sp, sp, -16
99 ; RV32-ILP32FD-NEXT: sw ra, 12(sp)
100 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI5_0)
101 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI5_0)
102 ; RV32-ILP32FD-NEXT: flw fa0, 0(a0)
103 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI5_1)
104 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI5_1)
105 ; RV32-ILP32FD-NEXT: flw fa1, 0(a0)
106 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI5_2)
107 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI5_2)
108 ; RV32-ILP32FD-NEXT: flw fa2, 0(a0)
109 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI5_3)
110 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI5_3)
111 ; RV32-ILP32FD-NEXT: flw fa3, 0(a0)
112 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI5_4)
113 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI5_4)
114 ; RV32-ILP32FD-NEXT: flw fa4, 0(a0)
115 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI5_5)
116 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI5_5)
117 ; RV32-ILP32FD-NEXT: flw fa5, 0(a0)
118 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI5_6)
119 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI5_6)
120 ; RV32-ILP32FD-NEXT: flw fa6, 0(a0)
121 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI5_7)
122 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI5_7)
123 ; RV32-ILP32FD-NEXT: flw fa7, 0(a0)
124 ; RV32-ILP32FD-NEXT: lui a0, 266496
125 ; RV32-ILP32FD-NEXT: call callee_float_in_gpr_exhausted_fprs
126 ; RV32-ILP32FD-NEXT: lw ra, 12(sp)
127 ; RV32-ILP32FD-NEXT: addi sp, sp, 16
128 ; RV32-ILP32FD-NEXT: ret
129 %1 = call i32 @callee_float_in_gpr_exhausted_fprs(
130 float 1.0, float 2.0, float 3.0, float 4.0, float 5.0, float 6.0,
131 float 7.0, float 8.0, float 9.0)
135 ; Must keep define on a single line due to an update_llc_test_checks.py limitation
136 define i32 @callee_float_on_stack_exhausted_gprs_fprs(i64 %a, float %b, i64 %c, float %d, i64 %e, float %f, i64 %g, float %h, float %i, float %j, float %k, float %l, float %m) nounwind {
137 ; RV32-ILP32FD-LABEL: callee_float_on_stack_exhausted_gprs_fprs:
138 ; RV32-ILP32FD: # %bb.0:
139 ; RV32-ILP32FD-NEXT: flw ft0, 0(sp)
140 ; RV32-ILP32FD-NEXT: fcvt.w.s a0, ft0, rtz
141 ; RV32-ILP32FD-NEXT: add a0, a6, a0
142 ; RV32-ILP32FD-NEXT: ret
143 %g_trunc = trunc i64 %g to i32
144 %m_fptosi = fptosi float %m to i32
145 %1 = add i32 %g_trunc, %m_fptosi
149 define i32 @caller_float_on_stack_exhausted_gprs_fprs() nounwind {
150 ; RV32-ILP32FD-LABEL: caller_float_on_stack_exhausted_gprs_fprs:
151 ; RV32-ILP32FD: # %bb.0:
152 ; RV32-ILP32FD-NEXT: addi sp, sp, -16
153 ; RV32-ILP32FD-NEXT: sw ra, 12(sp)
154 ; RV32-ILP32FD-NEXT: lui a1, 267520
155 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI7_0)
156 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI7_0)
157 ; RV32-ILP32FD-NEXT: flw fa0, 0(a0)
158 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI7_1)
159 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI7_1)
160 ; RV32-ILP32FD-NEXT: flw fa1, 0(a0)
161 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI7_2)
162 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI7_2)
163 ; RV32-ILP32FD-NEXT: flw fa2, 0(a0)
164 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI7_3)
165 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI7_3)
166 ; RV32-ILP32FD-NEXT: flw fa3, 0(a0)
167 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI7_4)
168 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI7_4)
169 ; RV32-ILP32FD-NEXT: flw fa4, 0(a0)
170 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI7_5)
171 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI7_5)
172 ; RV32-ILP32FD-NEXT: flw fa5, 0(a0)
173 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI7_6)
174 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI7_6)
175 ; RV32-ILP32FD-NEXT: flw fa6, 0(a0)
176 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI7_7)
177 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI7_7)
178 ; RV32-ILP32FD-NEXT: flw fa7, 0(a0)
179 ; RV32-ILP32FD-NEXT: addi a0, zero, 1
180 ; RV32-ILP32FD-NEXT: addi a2, zero, 3
181 ; RV32-ILP32FD-NEXT: addi a4, zero, 5
182 ; RV32-ILP32FD-NEXT: addi a6, zero, 7
183 ; RV32-ILP32FD-NEXT: sw a1, 0(sp)
184 ; RV32-ILP32FD-NEXT: mv a1, zero
185 ; RV32-ILP32FD-NEXT: mv a3, zero
186 ; RV32-ILP32FD-NEXT: mv a5, zero
187 ; RV32-ILP32FD-NEXT: mv a7, zero
188 ; RV32-ILP32FD-NEXT: call callee_float_on_stack_exhausted_gprs_fprs
189 ; RV32-ILP32FD-NEXT: lw ra, 12(sp)
190 ; RV32-ILP32FD-NEXT: addi sp, sp, 16
191 ; RV32-ILP32FD-NEXT: ret
192 %1 = call i32 @callee_float_on_stack_exhausted_gprs_fprs(
193 i64 1, float 2.0, i64 3, float 4.0, i64 5, float 6.0, i64 7, float 8.0,
194 float 9.0, float 10.0, float 11.0, float 12.0, float 13.0)
198 define float @callee_float_ret() nounwind {
199 ; RV32-ILP32FD-LABEL: callee_float_ret:
200 ; RV32-ILP32FD: # %bb.0:
201 ; RV32-ILP32FD-NEXT: lui a0, %hi(.LCPI8_0)
202 ; RV32-ILP32FD-NEXT: addi a0, a0, %lo(.LCPI8_0)
203 ; RV32-ILP32FD-NEXT: flw fa0, 0(a0)
204 ; RV32-ILP32FD-NEXT: ret
208 define i32 @caller_float_ret() nounwind {
209 ; RV32-ILP32FD-LABEL: caller_float_ret:
210 ; RV32-ILP32FD: # %bb.0:
211 ; RV32-ILP32FD-NEXT: addi sp, sp, -16
212 ; RV32-ILP32FD-NEXT: sw ra, 12(sp)
213 ; RV32-ILP32FD-NEXT: call callee_float_ret
214 ; RV32-ILP32FD-NEXT: fmv.x.w a0, fa0
215 ; RV32-ILP32FD-NEXT: lw ra, 12(sp)
216 ; RV32-ILP32FD-NEXT: addi sp, sp, 16
217 ; RV32-ILP32FD-NEXT: ret
218 %1 = call float @callee_float_ret()
219 %2 = bitcast float %1 to i32