Revert " [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)"
[llvm-project.git] / llvm / test / CodeGen / RISCV / calling-conv-ilp32e.ll
blobd08cf577b1bdd3e3dbb8a1f4e844e387f5a28b14
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -target-abi ilp32e -verify-machineinstrs < %s \
3 ; RUN:   | FileCheck -check-prefix=ILP32E-FPELIM %s
4 ; RUN: llc -mtriple=riscv32 -target-abi ilp32e -frame-pointer=all \
5 ; RUN:   -verify-machineinstrs < %s \
6 ; RUN:   | FileCheck -check-prefix=ILP32E-WITHFP %s
7 ; RUN: llc -mtriple=riscv32 -target-abi ilp32e -mattr=+save-restore -verify-machineinstrs < %s \
8 ; RUN:   | FileCheck -check-prefix=ILP32E-FPELIM-SAVE-RESTORE %s
9 ; RUN: llc -mtriple=riscv32 -target-abi ilp32e -mattr=+save-restore -frame-pointer=all \
10 ; RUN:   -verify-machineinstrs < %s \
11 ; RUN:   | FileCheck -check-prefix=ILP32E-WITHFP-SAVE-RESTORE %s
13 ; This file contains tests that will have differing output for the ilp32e ABIs.
15 define i32 @callee_float_in_regs(i32 %a, float %b) {
16 ; ILP32E-FPELIM-LABEL: callee_float_in_regs:
17 ; ILP32E-FPELIM:       # %bb.0:
18 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -8
19 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 8
20 ; ILP32E-FPELIM-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
21 ; ILP32E-FPELIM-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
22 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
23 ; ILP32E-FPELIM-NEXT:    .cfi_offset s0, -8
24 ; ILP32E-FPELIM-NEXT:    mv s0, a0
25 ; ILP32E-FPELIM-NEXT:    mv a0, a1
26 ; ILP32E-FPELIM-NEXT:    call __fixsfsi
27 ; ILP32E-FPELIM-NEXT:    add a0, s0, a0
28 ; ILP32E-FPELIM-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
29 ; ILP32E-FPELIM-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
30 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 8
31 ; ILP32E-FPELIM-NEXT:    ret
33 ; ILP32E-WITHFP-LABEL: callee_float_in_regs:
34 ; ILP32E-WITHFP:       # %bb.0:
35 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -12
36 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 12
37 ; ILP32E-WITHFP-NEXT:    sw ra, 8(sp) # 4-byte Folded Spill
38 ; ILP32E-WITHFP-NEXT:    sw s0, 4(sp) # 4-byte Folded Spill
39 ; ILP32E-WITHFP-NEXT:    sw s1, 0(sp) # 4-byte Folded Spill
40 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
41 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
42 ; ILP32E-WITHFP-NEXT:    .cfi_offset s1, -12
43 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 12
44 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
45 ; ILP32E-WITHFP-NEXT:    mv s1, a0
46 ; ILP32E-WITHFP-NEXT:    mv a0, a1
47 ; ILP32E-WITHFP-NEXT:    call __fixsfsi
48 ; ILP32E-WITHFP-NEXT:    add a0, s1, a0
49 ; ILP32E-WITHFP-NEXT:    lw ra, 8(sp) # 4-byte Folded Reload
50 ; ILP32E-WITHFP-NEXT:    lw s0, 4(sp) # 4-byte Folded Reload
51 ; ILP32E-WITHFP-NEXT:    lw s1, 0(sp) # 4-byte Folded Reload
52 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 12
53 ; ILP32E-WITHFP-NEXT:    ret
55 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_float_in_regs:
56 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
57 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
58 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
59 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
60 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
61 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    mv s0, a0
62 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    mv a0, a1
63 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call __fixsfsi
64 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, s0, a0
65 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
67 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_float_in_regs:
68 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
69 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_2
70 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 12
71 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
72 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
73 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s1, -12
74 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 12
75 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
76 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    mv s1, a0
77 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    mv a0, a1
78 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call __fixsfsi
79 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, s1, a0
80 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_2
81   %b_fptosi = fptosi float %b to i32
82   %1 = add i32 %a, %b_fptosi
83   ret i32 %1
86 define i32 @caller_float_in_regs() {
87 ; ILP32E-FPELIM-LABEL: caller_float_in_regs:
88 ; ILP32E-FPELIM:       # %bb.0:
89 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -4
90 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 4
91 ; ILP32E-FPELIM-NEXT:    sw ra, 0(sp) # 4-byte Folded Spill
92 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
93 ; ILP32E-FPELIM-NEXT:    li a0, 1
94 ; ILP32E-FPELIM-NEXT:    lui a1, 262144
95 ; ILP32E-FPELIM-NEXT:    call callee_float_in_regs
96 ; ILP32E-FPELIM-NEXT:    lw ra, 0(sp) # 4-byte Folded Reload
97 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 4
98 ; ILP32E-FPELIM-NEXT:    ret
100 ; ILP32E-WITHFP-LABEL: caller_float_in_regs:
101 ; ILP32E-WITHFP:       # %bb.0:
102 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
103 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
104 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
105 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
106 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
107 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
108 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
109 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
110 ; ILP32E-WITHFP-NEXT:    li a0, 1
111 ; ILP32E-WITHFP-NEXT:    lui a1, 262144
112 ; ILP32E-WITHFP-NEXT:    call callee_float_in_regs
113 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
114 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
115 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
116 ; ILP32E-WITHFP-NEXT:    ret
118 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_float_in_regs:
119 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
120 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_0
121 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 4
122 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
123 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 1
124 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a1, 262144
125 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_float_in_regs
126 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_0
128 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_float_in_regs:
129 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
130 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
131 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
132 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
133 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
134 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
135 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
136 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 1
137 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a1, 262144
138 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_float_in_regs
139 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
140   %1 = call i32 @callee_float_in_regs(i32 1, float 2.0)
141   ret i32 %1
144 define i32 @callee_float_on_stack(i64 %a, i64 %b, i64 %c, i64 %d, float %e) {
145 ; ILP32E-FPELIM-LABEL: callee_float_on_stack:
146 ; ILP32E-FPELIM:       # %bb.0:
147 ; ILP32E-FPELIM-NEXT:    lw a0, 8(sp)
148 ; ILP32E-FPELIM-NEXT:    lw a1, 0(sp)
149 ; ILP32E-FPELIM-NEXT:    add a0, a1, a0
150 ; ILP32E-FPELIM-NEXT:    ret
152 ; ILP32E-WITHFP-LABEL: callee_float_on_stack:
153 ; ILP32E-WITHFP:       # %bb.0:
154 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
155 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
156 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
157 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
158 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
159 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
160 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
161 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
162 ; ILP32E-WITHFP-NEXT:    lw a0, 8(s0)
163 ; ILP32E-WITHFP-NEXT:    lw a1, 0(s0)
164 ; ILP32E-WITHFP-NEXT:    add a0, a1, a0
165 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
166 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
167 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
168 ; ILP32E-WITHFP-NEXT:    ret
170 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_float_on_stack:
171 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
172 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a0, 8(sp)
173 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a1, 0(sp)
174 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a1, a0
175 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    ret
177 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_float_on_stack:
178 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
179 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
180 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
181 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
182 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
183 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
184 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
185 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a0, 8(s0)
186 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a1, 0(s0)
187 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a1, a0
188 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
189   %1 = trunc i64 %d to i32
190   %2 = bitcast float %e to i32
191   %3 = add i32 %1, %2
192   ret i32 %3
195 define i32 @caller_float_on_stack() {
196 ; ILP32E-FPELIM-LABEL: caller_float_on_stack:
197 ; ILP32E-FPELIM:       # %bb.0:
198 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -16
199 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 16
200 ; ILP32E-FPELIM-NEXT:    sw ra, 12(sp) # 4-byte Folded Spill
201 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
202 ; ILP32E-FPELIM-NEXT:    lui a0, 264704
203 ; ILP32E-FPELIM-NEXT:    sw a0, 8(sp)
204 ; ILP32E-FPELIM-NEXT:    sw zero, 4(sp)
205 ; ILP32E-FPELIM-NEXT:    li a1, 4
206 ; ILP32E-FPELIM-NEXT:    li a0, 1
207 ; ILP32E-FPELIM-NEXT:    li a2, 2
208 ; ILP32E-FPELIM-NEXT:    li a4, 3
209 ; ILP32E-FPELIM-NEXT:    sw a1, 0(sp)
210 ; ILP32E-FPELIM-NEXT:    li a1, 0
211 ; ILP32E-FPELIM-NEXT:    li a3, 0
212 ; ILP32E-FPELIM-NEXT:    li a5, 0
213 ; ILP32E-FPELIM-NEXT:    call callee_float_on_stack
214 ; ILP32E-FPELIM-NEXT:    lw ra, 12(sp) # 4-byte Folded Reload
215 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 16
216 ; ILP32E-FPELIM-NEXT:    ret
218 ; ILP32E-WITHFP-LABEL: caller_float_on_stack:
219 ; ILP32E-WITHFP:       # %bb.0:
220 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -20
221 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 20
222 ; ILP32E-WITHFP-NEXT:    sw ra, 16(sp) # 4-byte Folded Spill
223 ; ILP32E-WITHFP-NEXT:    sw s0, 12(sp) # 4-byte Folded Spill
224 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
225 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
226 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 20
227 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
228 ; ILP32E-WITHFP-NEXT:    lui a0, 264704
229 ; ILP32E-WITHFP-NEXT:    sw a0, 8(sp)
230 ; ILP32E-WITHFP-NEXT:    sw zero, 4(sp)
231 ; ILP32E-WITHFP-NEXT:    li a1, 4
232 ; ILP32E-WITHFP-NEXT:    li a0, 1
233 ; ILP32E-WITHFP-NEXT:    li a2, 2
234 ; ILP32E-WITHFP-NEXT:    li a4, 3
235 ; ILP32E-WITHFP-NEXT:    sw a1, 0(sp)
236 ; ILP32E-WITHFP-NEXT:    li a1, 0
237 ; ILP32E-WITHFP-NEXT:    li a3, 0
238 ; ILP32E-WITHFP-NEXT:    li a5, 0
239 ; ILP32E-WITHFP-NEXT:    call callee_float_on_stack
240 ; ILP32E-WITHFP-NEXT:    lw ra, 16(sp) # 4-byte Folded Reload
241 ; ILP32E-WITHFP-NEXT:    lw s0, 12(sp) # 4-byte Folded Reload
242 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 20
243 ; ILP32E-WITHFP-NEXT:    ret
245 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_float_on_stack:
246 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
247 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_0
248 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, -12
249 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 16
250 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
251 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a0, 264704
252 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 8(sp)
253 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 4(sp)
254 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 4
255 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 1
256 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a2, 2
257 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a4, 3
258 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a1, 0(sp)
259 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 0
260 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a3, 0
261 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a5, 0
262 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_float_on_stack
263 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, 12
264 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_0
266 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_float_on_stack:
267 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
268 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
269 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, -12
270 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 20
271 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
272 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
273 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 20
274 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
275 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a0, 264704
276 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 8(sp)
277 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 4(sp)
278 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 4
279 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 1
280 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a2, 2
281 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a4, 3
282 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a1, 0(sp)
283 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 0
284 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a3, 0
285 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a5, 0
286 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_float_on_stack
287 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, 12
288 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
289   %1 = call i32 @callee_float_on_stack(i64 1, i64 2, i64 3, i64 4, float 5.0)
290   ret i32 %1
293 define float @callee_tiny_scalar_ret() {
294 ; ILP32E-FPELIM-LABEL: callee_tiny_scalar_ret:
295 ; ILP32E-FPELIM:       # %bb.0:
296 ; ILP32E-FPELIM-NEXT:    lui a0, 260096
297 ; ILP32E-FPELIM-NEXT:    ret
299 ; ILP32E-WITHFP-LABEL: callee_tiny_scalar_ret:
300 ; ILP32E-WITHFP:       # %bb.0:
301 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
302 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
303 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
304 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
305 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
306 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
307 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
308 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
309 ; ILP32E-WITHFP-NEXT:    lui a0, 260096
310 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
311 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
312 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
313 ; ILP32E-WITHFP-NEXT:    ret
315 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_tiny_scalar_ret:
316 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
317 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a0, 260096
318 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    ret
320 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_tiny_scalar_ret:
321 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
322 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
323 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
324 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
325 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
326 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
327 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
328 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a0, 260096
329 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
330   ret float 1.0
333 define i32 @caller_tiny_scalar_ret() {
334 ; ILP32E-FPELIM-LABEL: caller_tiny_scalar_ret:
335 ; ILP32E-FPELIM:       # %bb.0:
336 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -4
337 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 4
338 ; ILP32E-FPELIM-NEXT:    sw ra, 0(sp) # 4-byte Folded Spill
339 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
340 ; ILP32E-FPELIM-NEXT:    call callee_tiny_scalar_ret
341 ; ILP32E-FPELIM-NEXT:    lw ra, 0(sp) # 4-byte Folded Reload
342 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 4
343 ; ILP32E-FPELIM-NEXT:    ret
345 ; ILP32E-WITHFP-LABEL: caller_tiny_scalar_ret:
346 ; ILP32E-WITHFP:       # %bb.0:
347 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
348 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
349 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
350 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
351 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
352 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
353 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
354 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
355 ; ILP32E-WITHFP-NEXT:    call callee_tiny_scalar_ret
356 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
357 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
358 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
359 ; ILP32E-WITHFP-NEXT:    ret
361 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_tiny_scalar_ret:
362 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
363 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_0
364 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 4
365 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
366 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_tiny_scalar_ret
367 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_0
369 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_tiny_scalar_ret:
370 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
371 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
372 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
373 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
374 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
375 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
376 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
377 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_tiny_scalar_ret
378 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
379   %1 = call float @callee_tiny_scalar_ret()
380   %2 = bitcast float %1 to i32
381   ret i32 %2
384 ; Check that on RV32 ilp32e, double is passed in a pair of registers. Unlike
385 ; the convention for varargs, this need not be an aligned pair.
387 define i32 @callee_double_in_regs(i32 %a, double %b) {
388 ; ILP32E-FPELIM-LABEL: callee_double_in_regs:
389 ; ILP32E-FPELIM:       # %bb.0:
390 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -8
391 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 8
392 ; ILP32E-FPELIM-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
393 ; ILP32E-FPELIM-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
394 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
395 ; ILP32E-FPELIM-NEXT:    .cfi_offset s0, -8
396 ; ILP32E-FPELIM-NEXT:    mv s0, a0
397 ; ILP32E-FPELIM-NEXT:    mv a0, a1
398 ; ILP32E-FPELIM-NEXT:    mv a1, a2
399 ; ILP32E-FPELIM-NEXT:    call __fixdfsi
400 ; ILP32E-FPELIM-NEXT:    add a0, s0, a0
401 ; ILP32E-FPELIM-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
402 ; ILP32E-FPELIM-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
403 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 8
404 ; ILP32E-FPELIM-NEXT:    ret
406 ; ILP32E-WITHFP-LABEL: callee_double_in_regs:
407 ; ILP32E-WITHFP:       # %bb.0:
408 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -12
409 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 12
410 ; ILP32E-WITHFP-NEXT:    sw ra, 8(sp) # 4-byte Folded Spill
411 ; ILP32E-WITHFP-NEXT:    sw s0, 4(sp) # 4-byte Folded Spill
412 ; ILP32E-WITHFP-NEXT:    sw s1, 0(sp) # 4-byte Folded Spill
413 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
414 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
415 ; ILP32E-WITHFP-NEXT:    .cfi_offset s1, -12
416 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 12
417 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
418 ; ILP32E-WITHFP-NEXT:    mv s1, a0
419 ; ILP32E-WITHFP-NEXT:    mv a0, a1
420 ; ILP32E-WITHFP-NEXT:    mv a1, a2
421 ; ILP32E-WITHFP-NEXT:    call __fixdfsi
422 ; ILP32E-WITHFP-NEXT:    add a0, s1, a0
423 ; ILP32E-WITHFP-NEXT:    lw ra, 8(sp) # 4-byte Folded Reload
424 ; ILP32E-WITHFP-NEXT:    lw s0, 4(sp) # 4-byte Folded Reload
425 ; ILP32E-WITHFP-NEXT:    lw s1, 0(sp) # 4-byte Folded Reload
426 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 12
427 ; ILP32E-WITHFP-NEXT:    ret
429 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_double_in_regs:
430 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
431 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
432 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
433 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
434 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
435 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    mv s0, a0
436 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    mv a0, a1
437 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    mv a1, a2
438 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call __fixdfsi
439 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, s0, a0
440 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
442 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_double_in_regs:
443 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
444 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_2
445 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 12
446 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
447 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
448 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s1, -12
449 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 12
450 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
451 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    mv s1, a0
452 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    mv a0, a1
453 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    mv a1, a2
454 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call __fixdfsi
455 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, s1, a0
456 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_2
457   %b_fptosi = fptosi double %b to i32
458   %1 = add i32 %a, %b_fptosi
459   ret i32 %1
462 define i32 @caller_double_in_regs() {
463 ; ILP32E-FPELIM-LABEL: caller_double_in_regs:
464 ; ILP32E-FPELIM:       # %bb.0:
465 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -4
466 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 4
467 ; ILP32E-FPELIM-NEXT:    sw ra, 0(sp) # 4-byte Folded Spill
468 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
469 ; ILP32E-FPELIM-NEXT:    li a0, 1
470 ; ILP32E-FPELIM-NEXT:    lui a2, 262144
471 ; ILP32E-FPELIM-NEXT:    li a1, 0
472 ; ILP32E-FPELIM-NEXT:    call callee_double_in_regs
473 ; ILP32E-FPELIM-NEXT:    lw ra, 0(sp) # 4-byte Folded Reload
474 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 4
475 ; ILP32E-FPELIM-NEXT:    ret
477 ; ILP32E-WITHFP-LABEL: caller_double_in_regs:
478 ; ILP32E-WITHFP:       # %bb.0:
479 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
480 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
481 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
482 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
483 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
484 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
485 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
486 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
487 ; ILP32E-WITHFP-NEXT:    li a0, 1
488 ; ILP32E-WITHFP-NEXT:    lui a2, 262144
489 ; ILP32E-WITHFP-NEXT:    li a1, 0
490 ; ILP32E-WITHFP-NEXT:    call callee_double_in_regs
491 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
492 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
493 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
494 ; ILP32E-WITHFP-NEXT:    ret
496 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_double_in_regs:
497 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
498 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_0
499 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 4
500 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
501 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 1
502 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a2, 262144
503 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 0
504 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_double_in_regs
505 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_0
507 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_double_in_regs:
508 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
509 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
510 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
511 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
512 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
513 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
514 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
515 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 1
516 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a2, 262144
517 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 0
518 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_double_in_regs
519 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
520   %1 = call i32 @callee_double_in_regs(i32 1, double 2.0)
521   ret i32 %1
524 ; Check 2x*xlen values are aligned appropriately when passed on the stack
525 ; Must keep define on a single line due to an update_llc_test_checks.py limitation
526 define i32 @callee_aligned_stack(i32 %a, i32 %b, fp128 %c, i32 %d, i32 %e, i64 %f, i32 %g, i32 %h, double %i, i32 %j, [2 x i32] %k) {
527 ; The double should be 8-byte aligned on the stack, but the two-element array
528 ; should only be 4-byte aligned
529 ; ILP32E-FPELIM-LABEL: callee_aligned_stack:
530 ; ILP32E-FPELIM:       # %bb.0:
531 ; ILP32E-FPELIM-NEXT:    lw a0, 0(a2)
532 ; ILP32E-FPELIM-NEXT:    lw a1, 12(sp)
533 ; ILP32E-FPELIM-NEXT:    lw a2, 4(sp)
534 ; ILP32E-FPELIM-NEXT:    lw a3, 8(sp)
535 ; ILP32E-FPELIM-NEXT:    lw a4, 24(sp)
536 ; ILP32E-FPELIM-NEXT:    lw a5, 20(sp)
537 ; ILP32E-FPELIM-NEXT:    add a0, a0, a2
538 ; ILP32E-FPELIM-NEXT:    add a1, a3, a1
539 ; ILP32E-FPELIM-NEXT:    add a0, a0, a1
540 ; ILP32E-FPELIM-NEXT:    add a4, a5, a4
541 ; ILP32E-FPELIM-NEXT:    add a0, a0, a4
542 ; ILP32E-FPELIM-NEXT:    ret
544 ; ILP32E-WITHFP-LABEL: callee_aligned_stack:
545 ; ILP32E-WITHFP:       # %bb.0:
546 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
547 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
548 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
549 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
550 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
551 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
552 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
553 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
554 ; ILP32E-WITHFP-NEXT:    lw a0, 0(a2)
555 ; ILP32E-WITHFP-NEXT:    lw a1, 12(s0)
556 ; ILP32E-WITHFP-NEXT:    lw a2, 4(s0)
557 ; ILP32E-WITHFP-NEXT:    lw a3, 8(s0)
558 ; ILP32E-WITHFP-NEXT:    lw a4, 24(s0)
559 ; ILP32E-WITHFP-NEXT:    lw a5, 20(s0)
560 ; ILP32E-WITHFP-NEXT:    add a0, a0, a2
561 ; ILP32E-WITHFP-NEXT:    add a1, a3, a1
562 ; ILP32E-WITHFP-NEXT:    add a0, a0, a1
563 ; ILP32E-WITHFP-NEXT:    add a4, a5, a4
564 ; ILP32E-WITHFP-NEXT:    add a0, a0, a4
565 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
566 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
567 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
568 ; ILP32E-WITHFP-NEXT:    ret
570 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_aligned_stack:
571 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
572 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a0, 0(a2)
573 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a1, 12(sp)
574 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a2, 4(sp)
575 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a3, 8(sp)
576 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a4, 24(sp)
577 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a5, 20(sp)
578 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a0, a2
579 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a1, a3, a1
580 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a0, a1
581 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a4, a5, a4
582 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a0, a4
583 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    ret
585 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_aligned_stack:
586 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
587 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
588 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
589 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
590 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
591 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
592 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
593 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a0, 0(a2)
594 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a1, 12(s0)
595 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a2, 4(s0)
596 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a3, 8(s0)
597 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a4, 24(s0)
598 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a5, 20(s0)
599 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a0, a2
600 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a1, a3, a1
601 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a0, a1
602 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a4, a5, a4
603 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a0, a4
604 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
605   %1 = bitcast fp128 %c to i128
606   %2 = trunc i128 %1 to i32
607   %3 = add i32 %2, %g
608   %4 = add i32 %3, %h
609   %5 = bitcast double %i to i64
610   %6 = trunc i64 %5 to i32
611   %7 = add i32 %4, %6
612   %8 = add i32 %7, %j
613   %9 = extractvalue [2 x i32] %k, 0
614   %10 = add i32 %8, %9
615   ret i32 %10
618 define void @caller_aligned_stack() {
619 ; The double should be 8-byte aligned on the stack, but the two-element array
620 ; should only be 4-byte aligned
621 ; ILP32E-FPELIM-LABEL: caller_aligned_stack:
622 ; ILP32E-FPELIM:       # %bb.0:
623 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -64
624 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 64
625 ; ILP32E-FPELIM-NEXT:    sw ra, 60(sp) # 4-byte Folded Spill
626 ; ILP32E-FPELIM-NEXT:    sw s0, 56(sp) # 4-byte Folded Spill
627 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
628 ; ILP32E-FPELIM-NEXT:    .cfi_offset s0, -8
629 ; ILP32E-FPELIM-NEXT:    addi s0, sp, 64
630 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa s0, 0
631 ; ILP32E-FPELIM-NEXT:    andi sp, sp, -16
632 ; ILP32E-FPELIM-NEXT:    li a0, 18
633 ; ILP32E-FPELIM-NEXT:    sw a0, 28(sp)
634 ; ILP32E-FPELIM-NEXT:    li a0, 17
635 ; ILP32E-FPELIM-NEXT:    sw a0, 24(sp)
636 ; ILP32E-FPELIM-NEXT:    li a0, 16
637 ; ILP32E-FPELIM-NEXT:    sw a0, 20(sp)
638 ; ILP32E-FPELIM-NEXT:    lui a0, 262236
639 ; ILP32E-FPELIM-NEXT:    addi a0, a0, 655
640 ; ILP32E-FPELIM-NEXT:    sw a0, 16(sp)
641 ; ILP32E-FPELIM-NEXT:    lui a0, 377487
642 ; ILP32E-FPELIM-NEXT:    addi a0, a0, 1475
643 ; ILP32E-FPELIM-NEXT:    sw a0, 12(sp)
644 ; ILP32E-FPELIM-NEXT:    li a0, 15
645 ; ILP32E-FPELIM-NEXT:    sw a0, 8(sp)
646 ; ILP32E-FPELIM-NEXT:    li a0, 14
647 ; ILP32E-FPELIM-NEXT:    sw a0, 4(sp)
648 ; ILP32E-FPELIM-NEXT:    li a0, 4
649 ; ILP32E-FPELIM-NEXT:    sw a0, 0(sp)
650 ; ILP32E-FPELIM-NEXT:    lui a0, 262153
651 ; ILP32E-FPELIM-NEXT:    addi a0, a0, 491
652 ; ILP32E-FPELIM-NEXT:    sw a0, 44(sp)
653 ; ILP32E-FPELIM-NEXT:    lui a0, 545260
654 ; ILP32E-FPELIM-NEXT:    addi a0, a0, -1967
655 ; ILP32E-FPELIM-NEXT:    sw a0, 40(sp)
656 ; ILP32E-FPELIM-NEXT:    lui a0, 964690
657 ; ILP32E-FPELIM-NEXT:    addi a0, a0, -328
658 ; ILP32E-FPELIM-NEXT:    sw a0, 36(sp)
659 ; ILP32E-FPELIM-NEXT:    lui a0, 335544
660 ; ILP32E-FPELIM-NEXT:    addi a6, a0, 1311
661 ; ILP32E-FPELIM-NEXT:    lui a0, 688509
662 ; ILP32E-FPELIM-NEXT:    addi a5, a0, -2048
663 ; ILP32E-FPELIM-NEXT:    li a0, 1
664 ; ILP32E-FPELIM-NEXT:    li a1, 11
665 ; ILP32E-FPELIM-NEXT:    addi a2, sp, 32
666 ; ILP32E-FPELIM-NEXT:    li a3, 12
667 ; ILP32E-FPELIM-NEXT:    li a4, 13
668 ; ILP32E-FPELIM-NEXT:    sw a6, 32(sp)
669 ; ILP32E-FPELIM-NEXT:    call callee_aligned_stack
670 ; ILP32E-FPELIM-NEXT:    addi sp, s0, -64
671 ; ILP32E-FPELIM-NEXT:    lw ra, 60(sp) # 4-byte Folded Reload
672 ; ILP32E-FPELIM-NEXT:    lw s0, 56(sp) # 4-byte Folded Reload
673 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 64
674 ; ILP32E-FPELIM-NEXT:    ret
676 ; ILP32E-WITHFP-LABEL: caller_aligned_stack:
677 ; ILP32E-WITHFP:       # %bb.0:
678 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -64
679 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 64
680 ; ILP32E-WITHFP-NEXT:    sw ra, 60(sp) # 4-byte Folded Spill
681 ; ILP32E-WITHFP-NEXT:    sw s0, 56(sp) # 4-byte Folded Spill
682 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
683 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
684 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 64
685 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
686 ; ILP32E-WITHFP-NEXT:    andi sp, sp, -16
687 ; ILP32E-WITHFP-NEXT:    li a0, 18
688 ; ILP32E-WITHFP-NEXT:    sw a0, 28(sp)
689 ; ILP32E-WITHFP-NEXT:    li a0, 17
690 ; ILP32E-WITHFP-NEXT:    sw a0, 24(sp)
691 ; ILP32E-WITHFP-NEXT:    li a0, 16
692 ; ILP32E-WITHFP-NEXT:    sw a0, 20(sp)
693 ; ILP32E-WITHFP-NEXT:    lui a0, 262236
694 ; ILP32E-WITHFP-NEXT:    addi a0, a0, 655
695 ; ILP32E-WITHFP-NEXT:    sw a0, 16(sp)
696 ; ILP32E-WITHFP-NEXT:    lui a0, 377487
697 ; ILP32E-WITHFP-NEXT:    addi a0, a0, 1475
698 ; ILP32E-WITHFP-NEXT:    sw a0, 12(sp)
699 ; ILP32E-WITHFP-NEXT:    li a0, 15
700 ; ILP32E-WITHFP-NEXT:    sw a0, 8(sp)
701 ; ILP32E-WITHFP-NEXT:    li a0, 14
702 ; ILP32E-WITHFP-NEXT:    sw a0, 4(sp)
703 ; ILP32E-WITHFP-NEXT:    li a0, 4
704 ; ILP32E-WITHFP-NEXT:    sw a0, 0(sp)
705 ; ILP32E-WITHFP-NEXT:    lui a0, 262153
706 ; ILP32E-WITHFP-NEXT:    addi a0, a0, 491
707 ; ILP32E-WITHFP-NEXT:    sw a0, 44(sp)
708 ; ILP32E-WITHFP-NEXT:    lui a0, 545260
709 ; ILP32E-WITHFP-NEXT:    addi a0, a0, -1967
710 ; ILP32E-WITHFP-NEXT:    sw a0, 40(sp)
711 ; ILP32E-WITHFP-NEXT:    lui a0, 964690
712 ; ILP32E-WITHFP-NEXT:    addi a0, a0, -328
713 ; ILP32E-WITHFP-NEXT:    sw a0, 36(sp)
714 ; ILP32E-WITHFP-NEXT:    lui a0, 335544
715 ; ILP32E-WITHFP-NEXT:    addi a6, a0, 1311
716 ; ILP32E-WITHFP-NEXT:    lui a0, 688509
717 ; ILP32E-WITHFP-NEXT:    addi a5, a0, -2048
718 ; ILP32E-WITHFP-NEXT:    li a0, 1
719 ; ILP32E-WITHFP-NEXT:    li a1, 11
720 ; ILP32E-WITHFP-NEXT:    addi a2, sp, 32
721 ; ILP32E-WITHFP-NEXT:    li a3, 12
722 ; ILP32E-WITHFP-NEXT:    li a4, 13
723 ; ILP32E-WITHFP-NEXT:    sw a6, 32(sp)
724 ; ILP32E-WITHFP-NEXT:    call callee_aligned_stack
725 ; ILP32E-WITHFP-NEXT:    addi sp, s0, -64
726 ; ILP32E-WITHFP-NEXT:    lw ra, 60(sp) # 4-byte Folded Reload
727 ; ILP32E-WITHFP-NEXT:    lw s0, 56(sp) # 4-byte Folded Reload
728 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 64
729 ; ILP32E-WITHFP-NEXT:    ret
731 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_aligned_stack:
732 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
733 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
734 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, -56
735 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 64
736 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
737 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
738 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi s0, sp, 64
739 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
740 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    andi sp, sp, -16
741 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 18
742 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 28(sp)
743 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 17
744 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 24(sp)
745 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 16
746 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 20(sp)
747 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a0, 262236
748 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi a0, a0, 655
749 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 16(sp)
750 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a0, 377487
751 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi a0, a0, 1475
752 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 12(sp)
753 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 15
754 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 8(sp)
755 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 14
756 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 4(sp)
757 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 4
758 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 0(sp)
759 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a0, 262153
760 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi a0, a0, 491
761 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 44(sp)
762 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a0, 545260
763 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi a0, a0, -1967
764 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 40(sp)
765 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a0, 964690
766 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi a0, a0, -328
767 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 36(sp)
768 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a0, 335544
769 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi a6, a0, 1311
770 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a0, 688509
771 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi a5, a0, -2048
772 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 1
773 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 11
774 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi a2, sp, 32
775 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a3, 12
776 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a4, 13
777 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a6, 32(sp)
778 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_aligned_stack
779 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, s0, -64
780 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, 56
781 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
783 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_aligned_stack:
784 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
785 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
786 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, -56
787 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 64
788 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
789 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
790 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 64
791 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
792 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    andi sp, sp, -16
793 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 18
794 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 28(sp)
795 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 17
796 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 24(sp)
797 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 16
798 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 20(sp)
799 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a0, 262236
800 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi a0, a0, 655
801 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 16(sp)
802 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a0, 377487
803 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi a0, a0, 1475
804 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 12(sp)
805 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 15
806 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 8(sp)
807 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 14
808 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 4(sp)
809 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 4
810 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 0(sp)
811 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a0, 262153
812 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi a0, a0, 491
813 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 44(sp)
814 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a0, 545260
815 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi a0, a0, -1967
816 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 40(sp)
817 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a0, 964690
818 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi a0, a0, -328
819 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 36(sp)
820 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a0, 335544
821 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi a6, a0, 1311
822 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a0, 688509
823 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi a5, a0, -2048
824 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 1
825 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 11
826 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi a2, sp, 32
827 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a3, 12
828 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a4, 13
829 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a6, 32(sp)
830 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_aligned_stack
831 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, s0, -64
832 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, 56
833 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
834   %1 = call i32 @callee_aligned_stack(i32 1, i32 11,
835     fp128 0xLEB851EB851EB851F400091EB851EB851, i32 12, i32 13,
836     i64 20000000000, i32 14, i32 15, double 2.720000e+00, i32 16,
837     [2 x i32] [i32 17, i32 18])
838   ret void
841 define double @callee_small_scalar_ret() {
842 ; ILP32E-FPELIM-LABEL: callee_small_scalar_ret:
843 ; ILP32E-FPELIM:       # %bb.0:
844 ; ILP32E-FPELIM-NEXT:    lui a1, 261888
845 ; ILP32E-FPELIM-NEXT:    li a0, 0
846 ; ILP32E-FPELIM-NEXT:    ret
848 ; ILP32E-WITHFP-LABEL: callee_small_scalar_ret:
849 ; ILP32E-WITHFP:       # %bb.0:
850 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
851 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
852 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
853 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
854 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
855 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
856 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
857 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
858 ; ILP32E-WITHFP-NEXT:    lui a1, 261888
859 ; ILP32E-WITHFP-NEXT:    li a0, 0
860 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
861 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
862 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
863 ; ILP32E-WITHFP-NEXT:    ret
865 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_small_scalar_ret:
866 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
867 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a1, 261888
868 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 0
869 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    ret
871 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_small_scalar_ret:
872 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
873 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
874 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
875 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
876 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
877 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
878 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
879 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a1, 261888
880 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 0
881 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
882   ret double 1.0
885 define i64 @caller_small_scalar_ret() {
886 ; ILP32E-FPELIM-LABEL: caller_small_scalar_ret:
887 ; ILP32E-FPELIM:       # %bb.0:
888 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -4
889 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 4
890 ; ILP32E-FPELIM-NEXT:    sw ra, 0(sp) # 4-byte Folded Spill
891 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
892 ; ILP32E-FPELIM-NEXT:    call callee_small_scalar_ret
893 ; ILP32E-FPELIM-NEXT:    lw ra, 0(sp) # 4-byte Folded Reload
894 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 4
895 ; ILP32E-FPELIM-NEXT:    ret
897 ; ILP32E-WITHFP-LABEL: caller_small_scalar_ret:
898 ; ILP32E-WITHFP:       # %bb.0:
899 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
900 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
901 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
902 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
903 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
904 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
905 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
906 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
907 ; ILP32E-WITHFP-NEXT:    call callee_small_scalar_ret
908 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
909 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
910 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
911 ; ILP32E-WITHFP-NEXT:    ret
913 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_small_scalar_ret:
914 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
915 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_0
916 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 4
917 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
918 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_small_scalar_ret
919 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_0
921 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_small_scalar_ret:
922 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
923 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
924 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
925 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
926 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
927 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
928 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
929 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_small_scalar_ret
930 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
931   %1 = call double @callee_small_scalar_ret()
932   %2 = bitcast double %1 to i64
933   ret i64 %2
936 ; Check that on RV32, i64 is passed in a pair of registers. Unlike
937 ; the convention for varargs, this need not be an aligned pair.
939 define i32 @callee_i64_in_regs(i32 %a, i64 %b) {
940 ; ILP32E-FPELIM-LABEL: callee_i64_in_regs:
941 ; ILP32E-FPELIM:       # %bb.0:
942 ; ILP32E-FPELIM-NEXT:    add a0, a0, a1
943 ; ILP32E-FPELIM-NEXT:    ret
945 ; ILP32E-WITHFP-LABEL: callee_i64_in_regs:
946 ; ILP32E-WITHFP:       # %bb.0:
947 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
948 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
949 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
950 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
951 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
952 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
953 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
954 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
955 ; ILP32E-WITHFP-NEXT:    add a0, a0, a1
956 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
957 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
958 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
959 ; ILP32E-WITHFP-NEXT:    ret
961 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_i64_in_regs:
962 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
963 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a0, a1
964 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    ret
966 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_i64_in_regs:
967 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
968 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
969 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
970 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
971 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
972 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
973 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
974 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a0, a1
975 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
976   %b_trunc = trunc i64 %b to i32
977   %1 = add i32 %a, %b_trunc
978   ret i32 %1
981 define i32 @caller_i64_in_regs() {
982 ; ILP32E-FPELIM-LABEL: caller_i64_in_regs:
983 ; ILP32E-FPELIM:       # %bb.0:
984 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -4
985 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 4
986 ; ILP32E-FPELIM-NEXT:    sw ra, 0(sp) # 4-byte Folded Spill
987 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
988 ; ILP32E-FPELIM-NEXT:    li a0, 1
989 ; ILP32E-FPELIM-NEXT:    li a1, 2
990 ; ILP32E-FPELIM-NEXT:    li a2, 0
991 ; ILP32E-FPELIM-NEXT:    call callee_i64_in_regs
992 ; ILP32E-FPELIM-NEXT:    lw ra, 0(sp) # 4-byte Folded Reload
993 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 4
994 ; ILP32E-FPELIM-NEXT:    ret
996 ; ILP32E-WITHFP-LABEL: caller_i64_in_regs:
997 ; ILP32E-WITHFP:       # %bb.0:
998 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
999 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
1000 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
1001 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
1002 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
1003 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
1004 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
1005 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
1006 ; ILP32E-WITHFP-NEXT:    li a0, 1
1007 ; ILP32E-WITHFP-NEXT:    li a1, 2
1008 ; ILP32E-WITHFP-NEXT:    li a2, 0
1009 ; ILP32E-WITHFP-NEXT:    call callee_i64_in_regs
1010 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
1011 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
1012 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
1013 ; ILP32E-WITHFP-NEXT:    ret
1015 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_i64_in_regs:
1016 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
1017 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_0
1018 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 4
1019 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1020 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 1
1021 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 2
1022 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a2, 0
1023 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_i64_in_regs
1024 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_0
1026 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_i64_in_regs:
1027 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
1028 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
1029 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
1030 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1031 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
1032 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
1033 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
1034 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 1
1035 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 2
1036 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a2, 0
1037 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_i64_in_regs
1038 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
1039   %1 = call i32 @callee_i64_in_regs(i32 1, i64 2)
1040   ret i32 %1
1043 ; Check that the stack is used once the GPRs are exhausted
1045 define i32 @callee_many_scalars(i8 %a, i16 %b, i32 %c, i64 %d, i32 %e, i32 %f, i64 %g, i32 %h) {
1046 ; ILP32E-FPELIM-LABEL: callee_many_scalars:
1047 ; ILP32E-FPELIM:       # %bb.0:
1048 ; ILP32E-FPELIM-NEXT:    lw a6, 12(sp)
1049 ; ILP32E-FPELIM-NEXT:    lw a7, 0(sp)
1050 ; ILP32E-FPELIM-NEXT:    lw t0, 4(sp)
1051 ; ILP32E-FPELIM-NEXT:    lw t1, 8(sp)
1052 ; ILP32E-FPELIM-NEXT:    andi a0, a0, 255
1053 ; ILP32E-FPELIM-NEXT:    slli a1, a1, 16
1054 ; ILP32E-FPELIM-NEXT:    srli a1, a1, 16
1055 ; ILP32E-FPELIM-NEXT:    add a0, a0, a2
1056 ; ILP32E-FPELIM-NEXT:    add a0, a0, a1
1057 ; ILP32E-FPELIM-NEXT:    xor a1, a4, t1
1058 ; ILP32E-FPELIM-NEXT:    xor a2, a3, t0
1059 ; ILP32E-FPELIM-NEXT:    or a1, a2, a1
1060 ; ILP32E-FPELIM-NEXT:    seqz a1, a1
1061 ; ILP32E-FPELIM-NEXT:    add a0, a0, a5
1062 ; ILP32E-FPELIM-NEXT:    add a0, a0, a7
1063 ; ILP32E-FPELIM-NEXT:    add a0, a0, a6
1064 ; ILP32E-FPELIM-NEXT:    add a0, a1, a0
1065 ; ILP32E-FPELIM-NEXT:    ret
1067 ; ILP32E-WITHFP-LABEL: callee_many_scalars:
1068 ; ILP32E-WITHFP:       # %bb.0:
1069 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
1070 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
1071 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
1072 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
1073 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
1074 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
1075 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
1076 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
1077 ; ILP32E-WITHFP-NEXT:    lw a6, 12(s0)
1078 ; ILP32E-WITHFP-NEXT:    lw a7, 0(s0)
1079 ; ILP32E-WITHFP-NEXT:    lw t0, 4(s0)
1080 ; ILP32E-WITHFP-NEXT:    lw t1, 8(s0)
1081 ; ILP32E-WITHFP-NEXT:    andi a0, a0, 255
1082 ; ILP32E-WITHFP-NEXT:    slli a1, a1, 16
1083 ; ILP32E-WITHFP-NEXT:    srli a1, a1, 16
1084 ; ILP32E-WITHFP-NEXT:    add a0, a0, a2
1085 ; ILP32E-WITHFP-NEXT:    add a0, a0, a1
1086 ; ILP32E-WITHFP-NEXT:    xor a1, a4, t1
1087 ; ILP32E-WITHFP-NEXT:    xor a2, a3, t0
1088 ; ILP32E-WITHFP-NEXT:    or a1, a2, a1
1089 ; ILP32E-WITHFP-NEXT:    seqz a1, a1
1090 ; ILP32E-WITHFP-NEXT:    add a0, a0, a5
1091 ; ILP32E-WITHFP-NEXT:    add a0, a0, a7
1092 ; ILP32E-WITHFP-NEXT:    add a0, a0, a6
1093 ; ILP32E-WITHFP-NEXT:    add a0, a1, a0
1094 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
1095 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
1096 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
1097 ; ILP32E-WITHFP-NEXT:    ret
1099 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_many_scalars:
1100 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
1101 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a6, 12(sp)
1102 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a7, 0(sp)
1103 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw t0, 4(sp)
1104 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw t1, 8(sp)
1105 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    andi a0, a0, 255
1106 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    slli a1, a1, 16
1107 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    srli a1, a1, 16
1108 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a0, a2
1109 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a0, a1
1110 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    xor a1, a4, t1
1111 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    xor a2, a3, t0
1112 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    or a1, a2, a1
1113 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    seqz a1, a1
1114 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a0, a5
1115 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a0, a7
1116 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a0, a6
1117 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a1, a0
1118 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    ret
1120 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_many_scalars:
1121 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
1122 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
1123 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
1124 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1125 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
1126 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
1127 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
1128 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a6, 12(s0)
1129 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a7, 0(s0)
1130 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw t0, 4(s0)
1131 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw t1, 8(s0)
1132 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    andi a0, a0, 255
1133 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    slli a1, a1, 16
1134 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    srli a1, a1, 16
1135 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a0, a2
1136 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a0, a1
1137 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    xor a1, a4, t1
1138 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    xor a2, a3, t0
1139 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    or a1, a2, a1
1140 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    seqz a1, a1
1141 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a0, a5
1142 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a0, a7
1143 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a0, a6
1144 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a1, a0
1145 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
1146   %a_ext = zext i8 %a to i32
1147   %b_ext = zext i16 %b to i32
1148   %1 = add i32 %a_ext, %b_ext
1149   %2 = add i32 %1, %c
1150   %3 = icmp eq i64 %d, %g
1151   %4 = zext i1 %3 to i32
1152   %5 = add i32 %4, %2
1153   %6 = add i32 %5, %e
1154   %7 = add i32 %6, %f
1155   %8 = add i32 %7, %h
1156   ret i32 %8
1159 define i32 @caller_many_scalars() {
1160 ; ILP32E-FPELIM-LABEL: caller_many_scalars:
1161 ; ILP32E-FPELIM:       # %bb.0:
1162 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -20
1163 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 20
1164 ; ILP32E-FPELIM-NEXT:    sw ra, 16(sp) # 4-byte Folded Spill
1165 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
1166 ; ILP32E-FPELIM-NEXT:    li a0, 8
1167 ; ILP32E-FPELIM-NEXT:    sw a0, 12(sp)
1168 ; ILP32E-FPELIM-NEXT:    sw zero, 8(sp)
1169 ; ILP32E-FPELIM-NEXT:    li a0, 7
1170 ; ILP32E-FPELIM-NEXT:    sw a0, 4(sp)
1171 ; ILP32E-FPELIM-NEXT:    li a4, 6
1172 ; ILP32E-FPELIM-NEXT:    li a0, 1
1173 ; ILP32E-FPELIM-NEXT:    li a1, 2
1174 ; ILP32E-FPELIM-NEXT:    li a2, 3
1175 ; ILP32E-FPELIM-NEXT:    li a3, 4
1176 ; ILP32E-FPELIM-NEXT:    li a5, 5
1177 ; ILP32E-FPELIM-NEXT:    sw a4, 0(sp)
1178 ; ILP32E-FPELIM-NEXT:    li a4, 0
1179 ; ILP32E-FPELIM-NEXT:    call callee_many_scalars
1180 ; ILP32E-FPELIM-NEXT:    lw ra, 16(sp) # 4-byte Folded Reload
1181 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 20
1182 ; ILP32E-FPELIM-NEXT:    ret
1184 ; ILP32E-WITHFP-LABEL: caller_many_scalars:
1185 ; ILP32E-WITHFP:       # %bb.0:
1186 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -24
1187 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 24
1188 ; ILP32E-WITHFP-NEXT:    sw ra, 20(sp) # 4-byte Folded Spill
1189 ; ILP32E-WITHFP-NEXT:    sw s0, 16(sp) # 4-byte Folded Spill
1190 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
1191 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
1192 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 24
1193 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
1194 ; ILP32E-WITHFP-NEXT:    li a0, 8
1195 ; ILP32E-WITHFP-NEXT:    sw a0, 12(sp)
1196 ; ILP32E-WITHFP-NEXT:    sw zero, 8(sp)
1197 ; ILP32E-WITHFP-NEXT:    li a0, 7
1198 ; ILP32E-WITHFP-NEXT:    sw a0, 4(sp)
1199 ; ILP32E-WITHFP-NEXT:    li a4, 6
1200 ; ILP32E-WITHFP-NEXT:    li a0, 1
1201 ; ILP32E-WITHFP-NEXT:    li a1, 2
1202 ; ILP32E-WITHFP-NEXT:    li a2, 3
1203 ; ILP32E-WITHFP-NEXT:    li a3, 4
1204 ; ILP32E-WITHFP-NEXT:    li a5, 5
1205 ; ILP32E-WITHFP-NEXT:    sw a4, 0(sp)
1206 ; ILP32E-WITHFP-NEXT:    li a4, 0
1207 ; ILP32E-WITHFP-NEXT:    call callee_many_scalars
1208 ; ILP32E-WITHFP-NEXT:    lw ra, 20(sp) # 4-byte Folded Reload
1209 ; ILP32E-WITHFP-NEXT:    lw s0, 16(sp) # 4-byte Folded Reload
1210 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 24
1211 ; ILP32E-WITHFP-NEXT:    ret
1213 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_many_scalars:
1214 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
1215 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_0
1216 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, -16
1217 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 20
1218 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1219 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 8
1220 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 12(sp)
1221 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 8(sp)
1222 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 7
1223 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 4(sp)
1224 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a4, 6
1225 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 1
1226 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 2
1227 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a2, 3
1228 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a3, 4
1229 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a5, 5
1230 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a4, 0(sp)
1231 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a4, 0
1232 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_many_scalars
1233 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, 16
1234 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_0
1236 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_many_scalars:
1237 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
1238 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
1239 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, -16
1240 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 24
1241 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1242 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
1243 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 24
1244 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
1245 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 8
1246 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 12(sp)
1247 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 8(sp)
1248 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 7
1249 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 4(sp)
1250 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a4, 6
1251 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 1
1252 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 2
1253 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a2, 3
1254 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a3, 4
1255 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a5, 5
1256 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a4, 0(sp)
1257 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a4, 0
1258 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_many_scalars
1259 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, 16
1260 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
1261   %1 = call i32 @callee_many_scalars(i8 1, i16 2, i32 3, i64 4, i32 5, i32 6, i64 7, i32 8)
1262   ret i32 %1
1265 ; Check that i128 and fp128 are passed indirectly
1267 define i32 @callee_large_scalars(i128 %a, fp128 %b) {
1268 ; ILP32E-FPELIM-LABEL: callee_large_scalars:
1269 ; ILP32E-FPELIM:       # %bb.0:
1270 ; ILP32E-FPELIM-NEXT:    lw a2, 0(a1)
1271 ; ILP32E-FPELIM-NEXT:    lw a3, 0(a0)
1272 ; ILP32E-FPELIM-NEXT:    lw a4, 4(a1)
1273 ; ILP32E-FPELIM-NEXT:    lw a5, 12(a1)
1274 ; ILP32E-FPELIM-NEXT:    lw a6, 12(a0)
1275 ; ILP32E-FPELIM-NEXT:    lw a7, 4(a0)
1276 ; ILP32E-FPELIM-NEXT:    lw a1, 8(a1)
1277 ; ILP32E-FPELIM-NEXT:    lw a0, 8(a0)
1278 ; ILP32E-FPELIM-NEXT:    xor a5, a6, a5
1279 ; ILP32E-FPELIM-NEXT:    xor a4, a7, a4
1280 ; ILP32E-FPELIM-NEXT:    or a4, a4, a5
1281 ; ILP32E-FPELIM-NEXT:    xor a0, a0, a1
1282 ; ILP32E-FPELIM-NEXT:    xor a2, a3, a2
1283 ; ILP32E-FPELIM-NEXT:    or a0, a2, a0
1284 ; ILP32E-FPELIM-NEXT:    or a0, a0, a4
1285 ; ILP32E-FPELIM-NEXT:    seqz a0, a0
1286 ; ILP32E-FPELIM-NEXT:    ret
1288 ; ILP32E-WITHFP-LABEL: callee_large_scalars:
1289 ; ILP32E-WITHFP:       # %bb.0:
1290 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
1291 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
1292 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
1293 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
1294 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
1295 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
1296 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
1297 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
1298 ; ILP32E-WITHFP-NEXT:    lw a2, 0(a1)
1299 ; ILP32E-WITHFP-NEXT:    lw a3, 0(a0)
1300 ; ILP32E-WITHFP-NEXT:    lw a4, 4(a1)
1301 ; ILP32E-WITHFP-NEXT:    lw a5, 12(a1)
1302 ; ILP32E-WITHFP-NEXT:    lw a6, 12(a0)
1303 ; ILP32E-WITHFP-NEXT:    lw a7, 4(a0)
1304 ; ILP32E-WITHFP-NEXT:    lw a1, 8(a1)
1305 ; ILP32E-WITHFP-NEXT:    lw a0, 8(a0)
1306 ; ILP32E-WITHFP-NEXT:    xor a5, a6, a5
1307 ; ILP32E-WITHFP-NEXT:    xor a4, a7, a4
1308 ; ILP32E-WITHFP-NEXT:    or a4, a4, a5
1309 ; ILP32E-WITHFP-NEXT:    xor a0, a0, a1
1310 ; ILP32E-WITHFP-NEXT:    xor a2, a3, a2
1311 ; ILP32E-WITHFP-NEXT:    or a0, a2, a0
1312 ; ILP32E-WITHFP-NEXT:    or a0, a0, a4
1313 ; ILP32E-WITHFP-NEXT:    seqz a0, a0
1314 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
1315 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
1316 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
1317 ; ILP32E-WITHFP-NEXT:    ret
1319 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_large_scalars:
1320 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
1321 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a2, 0(a1)
1322 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a3, 0(a0)
1323 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a4, 4(a1)
1324 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a5, 12(a1)
1325 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a6, 12(a0)
1326 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a7, 4(a0)
1327 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a1, 8(a1)
1328 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a0, 8(a0)
1329 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    xor a5, a6, a5
1330 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    xor a4, a7, a4
1331 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    or a4, a4, a5
1332 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    xor a0, a0, a1
1333 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    xor a2, a3, a2
1334 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    or a0, a2, a0
1335 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    or a0, a0, a4
1336 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    seqz a0, a0
1337 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    ret
1339 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_large_scalars:
1340 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
1341 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
1342 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
1343 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1344 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
1345 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
1346 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
1347 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a2, 0(a1)
1348 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a3, 0(a0)
1349 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a4, 4(a1)
1350 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a5, 12(a1)
1351 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a6, 12(a0)
1352 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a7, 4(a0)
1353 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a1, 8(a1)
1354 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a0, 8(a0)
1355 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    xor a5, a6, a5
1356 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    xor a4, a7, a4
1357 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    or a4, a4, a5
1358 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    xor a0, a0, a1
1359 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    xor a2, a3, a2
1360 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    or a0, a2, a0
1361 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    or a0, a0, a4
1362 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    seqz a0, a0
1363 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
1364   %b_bitcast = bitcast fp128 %b to i128
1365   %1 = icmp eq i128 %a, %b_bitcast
1366   %2 = zext i1 %1 to i32
1367   ret i32 %2
1370 define i32 @caller_large_scalars() {
1371 ; ILP32E-FPELIM-LABEL: caller_large_scalars:
1372 ; ILP32E-FPELIM:       # %bb.0:
1373 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -48
1374 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 48
1375 ; ILP32E-FPELIM-NEXT:    sw ra, 44(sp) # 4-byte Folded Spill
1376 ; ILP32E-FPELIM-NEXT:    sw s0, 40(sp) # 4-byte Folded Spill
1377 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
1378 ; ILP32E-FPELIM-NEXT:    .cfi_offset s0, -8
1379 ; ILP32E-FPELIM-NEXT:    addi s0, sp, 48
1380 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa s0, 0
1381 ; ILP32E-FPELIM-NEXT:    andi sp, sp, -16
1382 ; ILP32E-FPELIM-NEXT:    lui a0, 524272
1383 ; ILP32E-FPELIM-NEXT:    sw a0, 12(sp)
1384 ; ILP32E-FPELIM-NEXT:    sw zero, 8(sp)
1385 ; ILP32E-FPELIM-NEXT:    sw zero, 4(sp)
1386 ; ILP32E-FPELIM-NEXT:    sw zero, 0(sp)
1387 ; ILP32E-FPELIM-NEXT:    sw zero, 36(sp)
1388 ; ILP32E-FPELIM-NEXT:    sw zero, 32(sp)
1389 ; ILP32E-FPELIM-NEXT:    sw zero, 28(sp)
1390 ; ILP32E-FPELIM-NEXT:    li a2, 1
1391 ; ILP32E-FPELIM-NEXT:    addi a0, sp, 24
1392 ; ILP32E-FPELIM-NEXT:    mv a1, sp
1393 ; ILP32E-FPELIM-NEXT:    sw a2, 24(sp)
1394 ; ILP32E-FPELIM-NEXT:    call callee_large_scalars
1395 ; ILP32E-FPELIM-NEXT:    addi sp, s0, -48
1396 ; ILP32E-FPELIM-NEXT:    lw ra, 44(sp) # 4-byte Folded Reload
1397 ; ILP32E-FPELIM-NEXT:    lw s0, 40(sp) # 4-byte Folded Reload
1398 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 48
1399 ; ILP32E-FPELIM-NEXT:    ret
1401 ; ILP32E-WITHFP-LABEL: caller_large_scalars:
1402 ; ILP32E-WITHFP:       # %bb.0:
1403 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -48
1404 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 48
1405 ; ILP32E-WITHFP-NEXT:    sw ra, 44(sp) # 4-byte Folded Spill
1406 ; ILP32E-WITHFP-NEXT:    sw s0, 40(sp) # 4-byte Folded Spill
1407 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
1408 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
1409 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 48
1410 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
1411 ; ILP32E-WITHFP-NEXT:    andi sp, sp, -16
1412 ; ILP32E-WITHFP-NEXT:    lui a0, 524272
1413 ; ILP32E-WITHFP-NEXT:    sw a0, 12(sp)
1414 ; ILP32E-WITHFP-NEXT:    sw zero, 8(sp)
1415 ; ILP32E-WITHFP-NEXT:    sw zero, 4(sp)
1416 ; ILP32E-WITHFP-NEXT:    sw zero, 0(sp)
1417 ; ILP32E-WITHFP-NEXT:    sw zero, 36(sp)
1418 ; ILP32E-WITHFP-NEXT:    sw zero, 32(sp)
1419 ; ILP32E-WITHFP-NEXT:    sw zero, 28(sp)
1420 ; ILP32E-WITHFP-NEXT:    li a2, 1
1421 ; ILP32E-WITHFP-NEXT:    addi a0, sp, 24
1422 ; ILP32E-WITHFP-NEXT:    mv a1, sp
1423 ; ILP32E-WITHFP-NEXT:    sw a2, 24(sp)
1424 ; ILP32E-WITHFP-NEXT:    call callee_large_scalars
1425 ; ILP32E-WITHFP-NEXT:    addi sp, s0, -48
1426 ; ILP32E-WITHFP-NEXT:    lw ra, 44(sp) # 4-byte Folded Reload
1427 ; ILP32E-WITHFP-NEXT:    lw s0, 40(sp) # 4-byte Folded Reload
1428 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 48
1429 ; ILP32E-WITHFP-NEXT:    ret
1431 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_large_scalars:
1432 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
1433 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
1434 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, -40
1435 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 48
1436 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1437 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
1438 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi s0, sp, 48
1439 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
1440 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    andi sp, sp, -16
1441 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a0, 524272
1442 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 12(sp)
1443 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 8(sp)
1444 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 4(sp)
1445 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 0(sp)
1446 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 36(sp)
1447 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 32(sp)
1448 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 28(sp)
1449 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a2, 1
1450 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi a0, sp, 24
1451 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    mv a1, sp
1452 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a2, 24(sp)
1453 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_large_scalars
1454 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, s0, -48
1455 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, 40
1456 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
1458 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_large_scalars:
1459 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
1460 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
1461 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, -40
1462 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 48
1463 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1464 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
1465 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 48
1466 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
1467 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    andi sp, sp, -16
1468 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a0, 524272
1469 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 12(sp)
1470 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 8(sp)
1471 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 4(sp)
1472 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 0(sp)
1473 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 36(sp)
1474 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 32(sp)
1475 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 28(sp)
1476 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a2, 1
1477 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi a0, sp, 24
1478 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    mv a1, sp
1479 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a2, 24(sp)
1480 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_large_scalars
1481 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, s0, -48
1482 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, 40
1483 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
1484   %1 = call i32 @callee_large_scalars(i128 1, fp128 0xL00000000000000007FFF000000000000)
1485   ret i32 %1
1488 ; Check that arguments larger than 2*xlen are handled correctly when their
1489 ; address is passed on the stack rather than in memory
1491 ; Must keep define on a single line due to an update_llc_test_checks.py limitation
1492 define i32 @callee_large_scalars_exhausted_regs(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i128 %h, i32 %i, fp128 %j) {
1493 ; ILP32E-FPELIM-LABEL: callee_large_scalars_exhausted_regs:
1494 ; ILP32E-FPELIM:       # %bb.0:
1495 ; ILP32E-FPELIM-NEXT:    lw a0, 12(sp)
1496 ; ILP32E-FPELIM-NEXT:    lw a1, 4(sp)
1497 ; ILP32E-FPELIM-NEXT:    lw a2, 0(a0)
1498 ; ILP32E-FPELIM-NEXT:    lw a3, 0(a1)
1499 ; ILP32E-FPELIM-NEXT:    lw a4, 4(a0)
1500 ; ILP32E-FPELIM-NEXT:    lw a5, 12(a0)
1501 ; ILP32E-FPELIM-NEXT:    lw a6, 12(a1)
1502 ; ILP32E-FPELIM-NEXT:    lw a7, 4(a1)
1503 ; ILP32E-FPELIM-NEXT:    lw a0, 8(a0)
1504 ; ILP32E-FPELIM-NEXT:    lw a1, 8(a1)
1505 ; ILP32E-FPELIM-NEXT:    xor a5, a6, a5
1506 ; ILP32E-FPELIM-NEXT:    xor a4, a7, a4
1507 ; ILP32E-FPELIM-NEXT:    or a4, a4, a5
1508 ; ILP32E-FPELIM-NEXT:    xor a0, a1, a0
1509 ; ILP32E-FPELIM-NEXT:    xor a2, a3, a2
1510 ; ILP32E-FPELIM-NEXT:    or a0, a2, a0
1511 ; ILP32E-FPELIM-NEXT:    or a0, a0, a4
1512 ; ILP32E-FPELIM-NEXT:    seqz a0, a0
1513 ; ILP32E-FPELIM-NEXT:    ret
1515 ; ILP32E-WITHFP-LABEL: callee_large_scalars_exhausted_regs:
1516 ; ILP32E-WITHFP:       # %bb.0:
1517 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
1518 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
1519 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
1520 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
1521 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
1522 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
1523 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
1524 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
1525 ; ILP32E-WITHFP-NEXT:    lw a0, 12(s0)
1526 ; ILP32E-WITHFP-NEXT:    lw a1, 4(s0)
1527 ; ILP32E-WITHFP-NEXT:    lw a2, 0(a0)
1528 ; ILP32E-WITHFP-NEXT:    lw a3, 0(a1)
1529 ; ILP32E-WITHFP-NEXT:    lw a4, 4(a0)
1530 ; ILP32E-WITHFP-NEXT:    lw a5, 12(a0)
1531 ; ILP32E-WITHFP-NEXT:    lw a6, 12(a1)
1532 ; ILP32E-WITHFP-NEXT:    lw a7, 4(a1)
1533 ; ILP32E-WITHFP-NEXT:    lw a0, 8(a0)
1534 ; ILP32E-WITHFP-NEXT:    lw a1, 8(a1)
1535 ; ILP32E-WITHFP-NEXT:    xor a5, a6, a5
1536 ; ILP32E-WITHFP-NEXT:    xor a4, a7, a4
1537 ; ILP32E-WITHFP-NEXT:    or a4, a4, a5
1538 ; ILP32E-WITHFP-NEXT:    xor a0, a1, a0
1539 ; ILP32E-WITHFP-NEXT:    xor a2, a3, a2
1540 ; ILP32E-WITHFP-NEXT:    or a0, a2, a0
1541 ; ILP32E-WITHFP-NEXT:    or a0, a0, a4
1542 ; ILP32E-WITHFP-NEXT:    seqz a0, a0
1543 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
1544 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
1545 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
1546 ; ILP32E-WITHFP-NEXT:    ret
1548 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_large_scalars_exhausted_regs:
1549 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
1550 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a0, 12(sp)
1551 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a1, 4(sp)
1552 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a2, 0(a0)
1553 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a3, 0(a1)
1554 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a4, 4(a0)
1555 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a5, 12(a0)
1556 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a6, 12(a1)
1557 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a7, 4(a1)
1558 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a0, 8(a0)
1559 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a1, 8(a1)
1560 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    xor a5, a6, a5
1561 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    xor a4, a7, a4
1562 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    or a4, a4, a5
1563 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    xor a0, a1, a0
1564 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    xor a2, a3, a2
1565 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    or a0, a2, a0
1566 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    or a0, a0, a4
1567 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    seqz a0, a0
1568 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    ret
1570 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_large_scalars_exhausted_regs:
1571 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
1572 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
1573 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
1574 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1575 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
1576 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
1577 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
1578 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a0, 12(s0)
1579 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a1, 4(s0)
1580 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a2, 0(a0)
1581 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a3, 0(a1)
1582 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a4, 4(a0)
1583 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a5, 12(a0)
1584 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a6, 12(a1)
1585 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a7, 4(a1)
1586 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a0, 8(a0)
1587 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a1, 8(a1)
1588 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    xor a5, a6, a5
1589 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    xor a4, a7, a4
1590 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    or a4, a4, a5
1591 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    xor a0, a1, a0
1592 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    xor a2, a3, a2
1593 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    or a0, a2, a0
1594 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    or a0, a0, a4
1595 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    seqz a0, a0
1596 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
1597   %j_bitcast = bitcast fp128 %j to i128
1598   %1 = icmp eq i128 %h, %j_bitcast
1599   %2 = zext i1 %1 to i32
1600   ret i32 %2
1603 define i32 @caller_large_scalars_exhausted_regs() {
1604 ; ILP32E-FPELIM-LABEL: caller_large_scalars_exhausted_regs:
1605 ; ILP32E-FPELIM:       # %bb.0:
1606 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -64
1607 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 64
1608 ; ILP32E-FPELIM-NEXT:    sw ra, 60(sp) # 4-byte Folded Spill
1609 ; ILP32E-FPELIM-NEXT:    sw s0, 56(sp) # 4-byte Folded Spill
1610 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
1611 ; ILP32E-FPELIM-NEXT:    .cfi_offset s0, -8
1612 ; ILP32E-FPELIM-NEXT:    addi s0, sp, 64
1613 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa s0, 0
1614 ; ILP32E-FPELIM-NEXT:    andi sp, sp, -16
1615 ; ILP32E-FPELIM-NEXT:    addi a0, sp, 16
1616 ; ILP32E-FPELIM-NEXT:    sw a0, 12(sp)
1617 ; ILP32E-FPELIM-NEXT:    li a0, 9
1618 ; ILP32E-FPELIM-NEXT:    sw a0, 8(sp)
1619 ; ILP32E-FPELIM-NEXT:    addi a0, sp, 40
1620 ; ILP32E-FPELIM-NEXT:    sw a0, 4(sp)
1621 ; ILP32E-FPELIM-NEXT:    li a0, 7
1622 ; ILP32E-FPELIM-NEXT:    sw a0, 0(sp)
1623 ; ILP32E-FPELIM-NEXT:    lui a0, 524272
1624 ; ILP32E-FPELIM-NEXT:    sw a0, 28(sp)
1625 ; ILP32E-FPELIM-NEXT:    sw zero, 24(sp)
1626 ; ILP32E-FPELIM-NEXT:    sw zero, 20(sp)
1627 ; ILP32E-FPELIM-NEXT:    sw zero, 16(sp)
1628 ; ILP32E-FPELIM-NEXT:    sw zero, 52(sp)
1629 ; ILP32E-FPELIM-NEXT:    sw zero, 48(sp)
1630 ; ILP32E-FPELIM-NEXT:    li a0, 8
1631 ; ILP32E-FPELIM-NEXT:    sw a0, 40(sp)
1632 ; ILP32E-FPELIM-NEXT:    li a0, 1
1633 ; ILP32E-FPELIM-NEXT:    li a1, 2
1634 ; ILP32E-FPELIM-NEXT:    li a2, 3
1635 ; ILP32E-FPELIM-NEXT:    li a3, 4
1636 ; ILP32E-FPELIM-NEXT:    li a4, 5
1637 ; ILP32E-FPELIM-NEXT:    li a5, 6
1638 ; ILP32E-FPELIM-NEXT:    sw zero, 44(sp)
1639 ; ILP32E-FPELIM-NEXT:    call callee_large_scalars_exhausted_regs
1640 ; ILP32E-FPELIM-NEXT:    addi sp, s0, -64
1641 ; ILP32E-FPELIM-NEXT:    lw ra, 60(sp) # 4-byte Folded Reload
1642 ; ILP32E-FPELIM-NEXT:    lw s0, 56(sp) # 4-byte Folded Reload
1643 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 64
1644 ; ILP32E-FPELIM-NEXT:    ret
1646 ; ILP32E-WITHFP-LABEL: caller_large_scalars_exhausted_regs:
1647 ; ILP32E-WITHFP:       # %bb.0:
1648 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -64
1649 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 64
1650 ; ILP32E-WITHFP-NEXT:    sw ra, 60(sp) # 4-byte Folded Spill
1651 ; ILP32E-WITHFP-NEXT:    sw s0, 56(sp) # 4-byte Folded Spill
1652 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
1653 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
1654 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 64
1655 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
1656 ; ILP32E-WITHFP-NEXT:    andi sp, sp, -16
1657 ; ILP32E-WITHFP-NEXT:    addi a0, sp, 16
1658 ; ILP32E-WITHFP-NEXT:    sw a0, 12(sp)
1659 ; ILP32E-WITHFP-NEXT:    li a0, 9
1660 ; ILP32E-WITHFP-NEXT:    sw a0, 8(sp)
1661 ; ILP32E-WITHFP-NEXT:    addi a0, sp, 40
1662 ; ILP32E-WITHFP-NEXT:    sw a0, 4(sp)
1663 ; ILP32E-WITHFP-NEXT:    li a0, 7
1664 ; ILP32E-WITHFP-NEXT:    sw a0, 0(sp)
1665 ; ILP32E-WITHFP-NEXT:    lui a0, 524272
1666 ; ILP32E-WITHFP-NEXT:    sw a0, 28(sp)
1667 ; ILP32E-WITHFP-NEXT:    sw zero, 24(sp)
1668 ; ILP32E-WITHFP-NEXT:    sw zero, 20(sp)
1669 ; ILP32E-WITHFP-NEXT:    sw zero, 16(sp)
1670 ; ILP32E-WITHFP-NEXT:    sw zero, 52(sp)
1671 ; ILP32E-WITHFP-NEXT:    sw zero, 48(sp)
1672 ; ILP32E-WITHFP-NEXT:    li a0, 8
1673 ; ILP32E-WITHFP-NEXT:    sw a0, 40(sp)
1674 ; ILP32E-WITHFP-NEXT:    li a0, 1
1675 ; ILP32E-WITHFP-NEXT:    li a1, 2
1676 ; ILP32E-WITHFP-NEXT:    li a2, 3
1677 ; ILP32E-WITHFP-NEXT:    li a3, 4
1678 ; ILP32E-WITHFP-NEXT:    li a4, 5
1679 ; ILP32E-WITHFP-NEXT:    li a5, 6
1680 ; ILP32E-WITHFP-NEXT:    sw zero, 44(sp)
1681 ; ILP32E-WITHFP-NEXT:    call callee_large_scalars_exhausted_regs
1682 ; ILP32E-WITHFP-NEXT:    addi sp, s0, -64
1683 ; ILP32E-WITHFP-NEXT:    lw ra, 60(sp) # 4-byte Folded Reload
1684 ; ILP32E-WITHFP-NEXT:    lw s0, 56(sp) # 4-byte Folded Reload
1685 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 64
1686 ; ILP32E-WITHFP-NEXT:    ret
1688 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_large_scalars_exhausted_regs:
1689 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
1690 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
1691 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, -56
1692 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 64
1693 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1694 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
1695 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi s0, sp, 64
1696 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
1697 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    andi sp, sp, -16
1698 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi a0, sp, 16
1699 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 12(sp)
1700 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 9
1701 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 8(sp)
1702 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi a0, sp, 40
1703 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 4(sp)
1704 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 7
1705 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 0(sp)
1706 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a0, 524272
1707 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 28(sp)
1708 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 24(sp)
1709 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 20(sp)
1710 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 16(sp)
1711 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 52(sp)
1712 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 48(sp)
1713 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 8
1714 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 40(sp)
1715 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 1
1716 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 2
1717 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a2, 3
1718 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a3, 4
1719 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a4, 5
1720 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a5, 6
1721 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 44(sp)
1722 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_large_scalars_exhausted_regs
1723 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, s0, -64
1724 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, 56
1725 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
1727 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_large_scalars_exhausted_regs:
1728 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
1729 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
1730 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, -56
1731 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 64
1732 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1733 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
1734 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 64
1735 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
1736 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    andi sp, sp, -16
1737 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi a0, sp, 16
1738 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 12(sp)
1739 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 9
1740 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 8(sp)
1741 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi a0, sp, 40
1742 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 4(sp)
1743 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 7
1744 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 0(sp)
1745 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a0, 524272
1746 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 28(sp)
1747 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 24(sp)
1748 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 20(sp)
1749 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 16(sp)
1750 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 52(sp)
1751 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 48(sp)
1752 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 8
1753 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, 40(sp)
1754 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 1
1755 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 2
1756 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a2, 3
1757 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a3, 4
1758 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a4, 5
1759 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a5, 6
1760 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 44(sp)
1761 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_large_scalars_exhausted_regs
1762 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, s0, -64
1763 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, 56
1764 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
1765   %1 = call i32 @callee_large_scalars_exhausted_regs(
1766       i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i128 8, i32 9,
1767       fp128 0xL00000000000000007FFF000000000000)
1768   ret i32 %1
1771 ; Ensure that libcalls generated in the middle-end obey the calling convention
1773 define i32 @caller_mixed_scalar_libcalls(i64 %a) {
1774 ; ILP32E-FPELIM-LABEL: caller_mixed_scalar_libcalls:
1775 ; ILP32E-FPELIM:       # %bb.0:
1776 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -24
1777 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 24
1778 ; ILP32E-FPELIM-NEXT:    sw ra, 20(sp) # 4-byte Folded Spill
1779 ; ILP32E-FPELIM-NEXT:    sw s0, 16(sp) # 4-byte Folded Spill
1780 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
1781 ; ILP32E-FPELIM-NEXT:    .cfi_offset s0, -8
1782 ; ILP32E-FPELIM-NEXT:    addi s0, sp, 24
1783 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa s0, 0
1784 ; ILP32E-FPELIM-NEXT:    andi sp, sp, -8
1785 ; ILP32E-FPELIM-NEXT:    mv a2, a1
1786 ; ILP32E-FPELIM-NEXT:    mv a1, a0
1787 ; ILP32E-FPELIM-NEXT:    mv a0, sp
1788 ; ILP32E-FPELIM-NEXT:    call __floatditf
1789 ; ILP32E-FPELIM-NEXT:    lw a0, 0(sp)
1790 ; ILP32E-FPELIM-NEXT:    addi sp, s0, -24
1791 ; ILP32E-FPELIM-NEXT:    lw ra, 20(sp) # 4-byte Folded Reload
1792 ; ILP32E-FPELIM-NEXT:    lw s0, 16(sp) # 4-byte Folded Reload
1793 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 24
1794 ; ILP32E-FPELIM-NEXT:    ret
1796 ; ILP32E-WITHFP-LABEL: caller_mixed_scalar_libcalls:
1797 ; ILP32E-WITHFP:       # %bb.0:
1798 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -24
1799 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 24
1800 ; ILP32E-WITHFP-NEXT:    sw ra, 20(sp) # 4-byte Folded Spill
1801 ; ILP32E-WITHFP-NEXT:    sw s0, 16(sp) # 4-byte Folded Spill
1802 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
1803 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
1804 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 24
1805 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
1806 ; ILP32E-WITHFP-NEXT:    andi sp, sp, -8
1807 ; ILP32E-WITHFP-NEXT:    mv a2, a1
1808 ; ILP32E-WITHFP-NEXT:    mv a1, a0
1809 ; ILP32E-WITHFP-NEXT:    mv a0, sp
1810 ; ILP32E-WITHFP-NEXT:    call __floatditf
1811 ; ILP32E-WITHFP-NEXT:    lw a0, 0(sp)
1812 ; ILP32E-WITHFP-NEXT:    addi sp, s0, -24
1813 ; ILP32E-WITHFP-NEXT:    lw ra, 20(sp) # 4-byte Folded Reload
1814 ; ILP32E-WITHFP-NEXT:    lw s0, 16(sp) # 4-byte Folded Reload
1815 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 24
1816 ; ILP32E-WITHFP-NEXT:    ret
1818 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_mixed_scalar_libcalls:
1819 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
1820 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
1821 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, -16
1822 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 24
1823 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1824 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
1825 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi s0, sp, 24
1826 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
1827 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    andi sp, sp, -8
1828 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    mv a2, a1
1829 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    mv a1, a0
1830 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    mv a0, sp
1831 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call __floatditf
1832 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a0, 0(sp)
1833 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, s0, -24
1834 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, 16
1835 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
1837 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_mixed_scalar_libcalls:
1838 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
1839 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
1840 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, -16
1841 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 24
1842 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1843 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
1844 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 24
1845 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
1846 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    andi sp, sp, -8
1847 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    mv a2, a1
1848 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    mv a1, a0
1849 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    mv a0, sp
1850 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call __floatditf
1851 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a0, 0(sp)
1852 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, s0, -24
1853 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, 16
1854 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
1855   %1 = sitofp i64 %a to fp128
1856   %2 = bitcast fp128 %1 to i128
1857   %3 = trunc i128 %2 to i32
1858   ret i32 %3
1862 ; Check passing of coerced integer arrays
1864 %struct.small = type { i32, ptr }
1866 define i32 @callee_small_coerced_struct([2 x i32] %a.coerce) {
1867 ; ILP32E-FPELIM-LABEL: callee_small_coerced_struct:
1868 ; ILP32E-FPELIM:       # %bb.0:
1869 ; ILP32E-FPELIM-NEXT:    xor a0, a0, a1
1870 ; ILP32E-FPELIM-NEXT:    seqz a0, a0
1871 ; ILP32E-FPELIM-NEXT:    ret
1873 ; ILP32E-WITHFP-LABEL: callee_small_coerced_struct:
1874 ; ILP32E-WITHFP:       # %bb.0:
1875 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
1876 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
1877 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
1878 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
1879 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
1880 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
1881 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
1882 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
1883 ; ILP32E-WITHFP-NEXT:    xor a0, a0, a1
1884 ; ILP32E-WITHFP-NEXT:    seqz a0, a0
1885 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
1886 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
1887 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
1888 ; ILP32E-WITHFP-NEXT:    ret
1890 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_small_coerced_struct:
1891 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
1892 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    xor a0, a0, a1
1893 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    seqz a0, a0
1894 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    ret
1896 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_small_coerced_struct:
1897 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
1898 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
1899 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
1900 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1901 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
1902 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
1903 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
1904 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    xor a0, a0, a1
1905 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    seqz a0, a0
1906 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
1907   %1 = extractvalue [2 x i32] %a.coerce, 0
1908   %2 = extractvalue [2 x i32] %a.coerce, 1
1909   %3 = icmp eq i32 %1, %2
1910   %4 = zext i1 %3 to i32
1911   ret i32 %4
1914 define i32 @caller_small_coerced_struct() {
1915 ; ILP32E-FPELIM-LABEL: caller_small_coerced_struct:
1916 ; ILP32E-FPELIM:       # %bb.0:
1917 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -4
1918 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 4
1919 ; ILP32E-FPELIM-NEXT:    sw ra, 0(sp) # 4-byte Folded Spill
1920 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
1921 ; ILP32E-FPELIM-NEXT:    li a0, 1
1922 ; ILP32E-FPELIM-NEXT:    li a1, 2
1923 ; ILP32E-FPELIM-NEXT:    call callee_small_coerced_struct
1924 ; ILP32E-FPELIM-NEXT:    lw ra, 0(sp) # 4-byte Folded Reload
1925 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 4
1926 ; ILP32E-FPELIM-NEXT:    ret
1928 ; ILP32E-WITHFP-LABEL: caller_small_coerced_struct:
1929 ; ILP32E-WITHFP:       # %bb.0:
1930 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
1931 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
1932 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
1933 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
1934 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
1935 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
1936 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
1937 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
1938 ; ILP32E-WITHFP-NEXT:    li a0, 1
1939 ; ILP32E-WITHFP-NEXT:    li a1, 2
1940 ; ILP32E-WITHFP-NEXT:    call callee_small_coerced_struct
1941 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
1942 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
1943 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
1944 ; ILP32E-WITHFP-NEXT:    ret
1946 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_small_coerced_struct:
1947 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
1948 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_0
1949 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 4
1950 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1951 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 1
1952 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 2
1953 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_small_coerced_struct
1954 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_0
1956 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_small_coerced_struct:
1957 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
1958 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
1959 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
1960 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
1961 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
1962 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
1963 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
1964 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 1
1965 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 2
1966 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_small_coerced_struct
1967 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
1968   %1 = call i32 @callee_small_coerced_struct([2 x i32] [i32 1, i32 2])
1969   ret i32 %1
1972 ; Check large struct arguments, which are passed byval
1974 %struct.large = type { i32, i32, i32, i32 }
1976 define i32 @callee_large_struct(ptr byval(%struct.large) align 4 %a) {
1977 ; ILP32E-FPELIM-LABEL: callee_large_struct:
1978 ; ILP32E-FPELIM:       # %bb.0:
1979 ; ILP32E-FPELIM-NEXT:    lw a1, 0(a0)
1980 ; ILP32E-FPELIM-NEXT:    lw a0, 12(a0)
1981 ; ILP32E-FPELIM-NEXT:    add a0, a1, a0
1982 ; ILP32E-FPELIM-NEXT:    ret
1984 ; ILP32E-WITHFP-LABEL: callee_large_struct:
1985 ; ILP32E-WITHFP:       # %bb.0:
1986 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
1987 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
1988 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
1989 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
1990 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
1991 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
1992 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
1993 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
1994 ; ILP32E-WITHFP-NEXT:    lw a1, 0(a0)
1995 ; ILP32E-WITHFP-NEXT:    lw a0, 12(a0)
1996 ; ILP32E-WITHFP-NEXT:    add a0, a1, a0
1997 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
1998 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
1999 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
2000 ; ILP32E-WITHFP-NEXT:    ret
2002 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_large_struct:
2003 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
2004 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a1, 0(a0)
2005 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a0, 12(a0)
2006 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a1, a0
2007 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    ret
2009 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_large_struct:
2010 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
2011 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
2012 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
2013 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
2014 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
2015 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
2016 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
2017 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a1, 0(a0)
2018 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a0, 12(a0)
2019 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a1, a0
2020 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
2021   %1 = getelementptr inbounds %struct.large, ptr %a, i32 0, i32 0
2022   %2 = getelementptr inbounds %struct.large, ptr %a, i32 0, i32 3
2023   %3 = load i32, ptr %1
2024   %4 = load i32, ptr %2
2025   %5 = add i32 %3, %4
2026   ret i32 %5
2029 define i32 @caller_large_struct() {
2030 ; ILP32E-FPELIM-LABEL: caller_large_struct:
2031 ; ILP32E-FPELIM:       # %bb.0:
2032 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -36
2033 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 36
2034 ; ILP32E-FPELIM-NEXT:    sw ra, 32(sp) # 4-byte Folded Spill
2035 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
2036 ; ILP32E-FPELIM-NEXT:    li a0, 1
2037 ; ILP32E-FPELIM-NEXT:    sw a0, 16(sp)
2038 ; ILP32E-FPELIM-NEXT:    li a1, 2
2039 ; ILP32E-FPELIM-NEXT:    sw a1, 20(sp)
2040 ; ILP32E-FPELIM-NEXT:    li a2, 3
2041 ; ILP32E-FPELIM-NEXT:    sw a2, 24(sp)
2042 ; ILP32E-FPELIM-NEXT:    li a3, 4
2043 ; ILP32E-FPELIM-NEXT:    sw a3, 28(sp)
2044 ; ILP32E-FPELIM-NEXT:    sw a0, 0(sp)
2045 ; ILP32E-FPELIM-NEXT:    sw a1, 4(sp)
2046 ; ILP32E-FPELIM-NEXT:    sw a2, 8(sp)
2047 ; ILP32E-FPELIM-NEXT:    sw a3, 12(sp)
2048 ; ILP32E-FPELIM-NEXT:    mv a0, sp
2049 ; ILP32E-FPELIM-NEXT:    call callee_large_struct
2050 ; ILP32E-FPELIM-NEXT:    lw ra, 32(sp) # 4-byte Folded Reload
2051 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 36
2052 ; ILP32E-FPELIM-NEXT:    ret
2054 ; ILP32E-WITHFP-LABEL: caller_large_struct:
2055 ; ILP32E-WITHFP:       # %bb.0:
2056 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -40
2057 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 40
2058 ; ILP32E-WITHFP-NEXT:    sw ra, 36(sp) # 4-byte Folded Spill
2059 ; ILP32E-WITHFP-NEXT:    sw s0, 32(sp) # 4-byte Folded Spill
2060 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
2061 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
2062 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 40
2063 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
2064 ; ILP32E-WITHFP-NEXT:    li a0, 1
2065 ; ILP32E-WITHFP-NEXT:    sw a0, -24(s0)
2066 ; ILP32E-WITHFP-NEXT:    li a1, 2
2067 ; ILP32E-WITHFP-NEXT:    sw a1, -20(s0)
2068 ; ILP32E-WITHFP-NEXT:    li a2, 3
2069 ; ILP32E-WITHFP-NEXT:    sw a2, -16(s0)
2070 ; ILP32E-WITHFP-NEXT:    li a3, 4
2071 ; ILP32E-WITHFP-NEXT:    sw a3, -12(s0)
2072 ; ILP32E-WITHFP-NEXT:    sw a0, -40(s0)
2073 ; ILP32E-WITHFP-NEXT:    sw a1, -36(s0)
2074 ; ILP32E-WITHFP-NEXT:    sw a2, -32(s0)
2075 ; ILP32E-WITHFP-NEXT:    sw a3, -28(s0)
2076 ; ILP32E-WITHFP-NEXT:    addi a0, s0, -40
2077 ; ILP32E-WITHFP-NEXT:    call callee_large_struct
2078 ; ILP32E-WITHFP-NEXT:    lw ra, 36(sp) # 4-byte Folded Reload
2079 ; ILP32E-WITHFP-NEXT:    lw s0, 32(sp) # 4-byte Folded Reload
2080 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 40
2081 ; ILP32E-WITHFP-NEXT:    ret
2083 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_large_struct:
2084 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
2085 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_0
2086 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, -32
2087 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 36
2088 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
2089 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 1
2090 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 16(sp)
2091 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 2
2092 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a1, 20(sp)
2093 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a2, 3
2094 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a2, 24(sp)
2095 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a3, 4
2096 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a3, 28(sp)
2097 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a0, 0(sp)
2098 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a1, 4(sp)
2099 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a2, 8(sp)
2100 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a3, 12(sp)
2101 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    mv a0, sp
2102 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_large_struct
2103 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, 32
2104 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_0
2106 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_large_struct:
2107 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
2108 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
2109 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, -32
2110 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 40
2111 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
2112 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
2113 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 40
2114 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
2115 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 1
2116 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, -24(s0)
2117 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 2
2118 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a1, -20(s0)
2119 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a2, 3
2120 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a2, -16(s0)
2121 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a3, 4
2122 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a3, -12(s0)
2123 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a0, -40(s0)
2124 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a1, -36(s0)
2125 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a2, -32(s0)
2126 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a3, -28(s0)
2127 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi a0, s0, -40
2128 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_large_struct
2129 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, 32
2130 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
2131   %ls = alloca %struct.large, align 4
2132   %1 = bitcast ptr %ls to ptr
2133   %a = getelementptr inbounds %struct.large, ptr %ls, i32 0, i32 0
2134   store i32 1, ptr %a
2135   %b = getelementptr inbounds %struct.large, ptr %ls, i32 0, i32 1
2136   store i32 2, ptr %b
2137   %c = getelementptr inbounds %struct.large, ptr %ls, i32 0, i32 2
2138   store i32 3, ptr %c
2139   %d = getelementptr inbounds %struct.large, ptr %ls, i32 0, i32 3
2140   store i32 4, ptr %d
2141   %2 = call i32 @callee_large_struct(ptr byval(%struct.large) align 4 %ls)
2142   ret i32 %2
2145 ; Check return of 2x xlen structs
2147 define %struct.small @callee_small_struct_ret() {
2148 ; ILP32E-FPELIM-LABEL: callee_small_struct_ret:
2149 ; ILP32E-FPELIM:       # %bb.0:
2150 ; ILP32E-FPELIM-NEXT:    li a0, 1
2151 ; ILP32E-FPELIM-NEXT:    li a1, 0
2152 ; ILP32E-FPELIM-NEXT:    ret
2154 ; ILP32E-WITHFP-LABEL: callee_small_struct_ret:
2155 ; ILP32E-WITHFP:       # %bb.0:
2156 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
2157 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
2158 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
2159 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
2160 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
2161 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
2162 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
2163 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
2164 ; ILP32E-WITHFP-NEXT:    li a0, 1
2165 ; ILP32E-WITHFP-NEXT:    li a1, 0
2166 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
2167 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
2168 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
2169 ; ILP32E-WITHFP-NEXT:    ret
2171 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_small_struct_ret:
2172 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
2173 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a0, 1
2174 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 0
2175 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    ret
2177 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_small_struct_ret:
2178 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
2179 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
2180 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
2181 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
2182 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
2183 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
2184 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
2185 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a0, 1
2186 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 0
2187 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
2188   ret %struct.small { i32 1, ptr null }
2191 define i32 @caller_small_struct_ret() {
2192 ; ILP32E-FPELIM-LABEL: caller_small_struct_ret:
2193 ; ILP32E-FPELIM:       # %bb.0:
2194 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -4
2195 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 4
2196 ; ILP32E-FPELIM-NEXT:    sw ra, 0(sp) # 4-byte Folded Spill
2197 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
2198 ; ILP32E-FPELIM-NEXT:    call callee_small_struct_ret
2199 ; ILP32E-FPELIM-NEXT:    add a0, a0, a1
2200 ; ILP32E-FPELIM-NEXT:    lw ra, 0(sp) # 4-byte Folded Reload
2201 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 4
2202 ; ILP32E-FPELIM-NEXT:    ret
2204 ; ILP32E-WITHFP-LABEL: caller_small_struct_ret:
2205 ; ILP32E-WITHFP:       # %bb.0:
2206 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
2207 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
2208 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
2209 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
2210 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
2211 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
2212 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
2213 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
2214 ; ILP32E-WITHFP-NEXT:    call callee_small_struct_ret
2215 ; ILP32E-WITHFP-NEXT:    add a0, a0, a1
2216 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
2217 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
2218 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
2219 ; ILP32E-WITHFP-NEXT:    ret
2221 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_small_struct_ret:
2222 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
2223 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_0
2224 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 4
2225 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
2226 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_small_struct_ret
2227 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a0, a1
2228 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_0
2230 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_small_struct_ret:
2231 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
2232 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
2233 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
2234 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
2235 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
2236 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
2237 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
2238 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_small_struct_ret
2239 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a0, a1
2240 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
2241   %1 = call %struct.small @callee_small_struct_ret()
2242   %2 = extractvalue %struct.small %1, 0
2243   %3 = extractvalue %struct.small %1, 1
2244   %4 = ptrtoint ptr %3 to i32
2245   %5 = add i32 %2, %4
2246   ret i32 %5
2249 ; Check return of >2x xlen scalars
2251 define fp128 @callee_large_scalar_ret() {
2252 ; ILP32E-FPELIM-LABEL: callee_large_scalar_ret:
2253 ; ILP32E-FPELIM:       # %bb.0:
2254 ; ILP32E-FPELIM-NEXT:    lui a1, 524272
2255 ; ILP32E-FPELIM-NEXT:    sw a1, 12(a0)
2256 ; ILP32E-FPELIM-NEXT:    sw zero, 8(a0)
2257 ; ILP32E-FPELIM-NEXT:    sw zero, 4(a0)
2258 ; ILP32E-FPELIM-NEXT:    sw zero, 0(a0)
2259 ; ILP32E-FPELIM-NEXT:    ret
2261 ; ILP32E-WITHFP-LABEL: callee_large_scalar_ret:
2262 ; ILP32E-WITHFP:       # %bb.0:
2263 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
2264 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
2265 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
2266 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
2267 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
2268 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
2269 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
2270 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
2271 ; ILP32E-WITHFP-NEXT:    lui a1, 524272
2272 ; ILP32E-WITHFP-NEXT:    sw a1, 12(a0)
2273 ; ILP32E-WITHFP-NEXT:    sw zero, 8(a0)
2274 ; ILP32E-WITHFP-NEXT:    sw zero, 4(a0)
2275 ; ILP32E-WITHFP-NEXT:    sw zero, 0(a0)
2276 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
2277 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
2278 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
2279 ; ILP32E-WITHFP-NEXT:    ret
2281 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_large_scalar_ret:
2282 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
2283 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lui a1, 524272
2284 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a1, 12(a0)
2285 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 8(a0)
2286 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 4(a0)
2287 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw zero, 0(a0)
2288 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    ret
2290 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_large_scalar_ret:
2291 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
2292 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
2293 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
2294 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
2295 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
2296 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
2297 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
2298 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lui a1, 524272
2299 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a1, 12(a0)
2300 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 8(a0)
2301 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 4(a0)
2302 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw zero, 0(a0)
2303 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
2304   ret fp128 0xL00000000000000007FFF000000000000
2307 define void @caller_large_scalar_ret() {
2308 ; ILP32E-FPELIM-LABEL: caller_large_scalar_ret:
2309 ; ILP32E-FPELIM:       # %bb.0:
2310 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -32
2311 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 32
2312 ; ILP32E-FPELIM-NEXT:    sw ra, 28(sp) # 4-byte Folded Spill
2313 ; ILP32E-FPELIM-NEXT:    sw s0, 24(sp) # 4-byte Folded Spill
2314 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
2315 ; ILP32E-FPELIM-NEXT:    .cfi_offset s0, -8
2316 ; ILP32E-FPELIM-NEXT:    addi s0, sp, 32
2317 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa s0, 0
2318 ; ILP32E-FPELIM-NEXT:    andi sp, sp, -16
2319 ; ILP32E-FPELIM-NEXT:    mv a0, sp
2320 ; ILP32E-FPELIM-NEXT:    call callee_large_scalar_ret
2321 ; ILP32E-FPELIM-NEXT:    addi sp, s0, -32
2322 ; ILP32E-FPELIM-NEXT:    lw ra, 28(sp) # 4-byte Folded Reload
2323 ; ILP32E-FPELIM-NEXT:    lw s0, 24(sp) # 4-byte Folded Reload
2324 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 32
2325 ; ILP32E-FPELIM-NEXT:    ret
2327 ; ILP32E-WITHFP-LABEL: caller_large_scalar_ret:
2328 ; ILP32E-WITHFP:       # %bb.0:
2329 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -32
2330 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 32
2331 ; ILP32E-WITHFP-NEXT:    sw ra, 28(sp) # 4-byte Folded Spill
2332 ; ILP32E-WITHFP-NEXT:    sw s0, 24(sp) # 4-byte Folded Spill
2333 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
2334 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
2335 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 32
2336 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
2337 ; ILP32E-WITHFP-NEXT:    andi sp, sp, -16
2338 ; ILP32E-WITHFP-NEXT:    mv a0, sp
2339 ; ILP32E-WITHFP-NEXT:    call callee_large_scalar_ret
2340 ; ILP32E-WITHFP-NEXT:    addi sp, s0, -32
2341 ; ILP32E-WITHFP-NEXT:    lw ra, 28(sp) # 4-byte Folded Reload
2342 ; ILP32E-WITHFP-NEXT:    lw s0, 24(sp) # 4-byte Folded Reload
2343 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 32
2344 ; ILP32E-WITHFP-NEXT:    ret
2346 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_large_scalar_ret:
2347 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
2348 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
2349 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, -24
2350 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 32
2351 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
2352 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
2353 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi s0, sp, 32
2354 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
2355 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    andi sp, sp, -16
2356 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    mv a0, sp
2357 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_large_scalar_ret
2358 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, s0, -32
2359 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, 24
2360 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
2362 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_large_scalar_ret:
2363 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
2364 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
2365 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, -24
2366 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 32
2367 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
2368 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
2369 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 32
2370 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
2371 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    andi sp, sp, -16
2372 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    mv a0, sp
2373 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_large_scalar_ret
2374 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, s0, -32
2375 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, 24
2376 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
2377   %1 = call fp128 @callee_large_scalar_ret()
2378   ret void
2381 ; Check return of >2x xlen structs
2383 define void @callee_large_struct_ret(ptr noalias sret(%struct.large) %agg.result) {
2384 ; ILP32E-FPELIM-LABEL: callee_large_struct_ret:
2385 ; ILP32E-FPELIM:       # %bb.0:
2386 ; ILP32E-FPELIM-NEXT:    li a1, 1
2387 ; ILP32E-FPELIM-NEXT:    sw a1, 0(a0)
2388 ; ILP32E-FPELIM-NEXT:    li a1, 2
2389 ; ILP32E-FPELIM-NEXT:    sw a1, 4(a0)
2390 ; ILP32E-FPELIM-NEXT:    li a1, 3
2391 ; ILP32E-FPELIM-NEXT:    sw a1, 8(a0)
2392 ; ILP32E-FPELIM-NEXT:    li a1, 4
2393 ; ILP32E-FPELIM-NEXT:    sw a1, 12(a0)
2394 ; ILP32E-FPELIM-NEXT:    ret
2396 ; ILP32E-WITHFP-LABEL: callee_large_struct_ret:
2397 ; ILP32E-WITHFP:       # %bb.0:
2398 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -8
2399 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 8
2400 ; ILP32E-WITHFP-NEXT:    sw ra, 4(sp) # 4-byte Folded Spill
2401 ; ILP32E-WITHFP-NEXT:    sw s0, 0(sp) # 4-byte Folded Spill
2402 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
2403 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
2404 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 8
2405 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
2406 ; ILP32E-WITHFP-NEXT:    li a1, 1
2407 ; ILP32E-WITHFP-NEXT:    sw a1, 0(a0)
2408 ; ILP32E-WITHFP-NEXT:    li a1, 2
2409 ; ILP32E-WITHFP-NEXT:    sw a1, 4(a0)
2410 ; ILP32E-WITHFP-NEXT:    li a1, 3
2411 ; ILP32E-WITHFP-NEXT:    sw a1, 8(a0)
2412 ; ILP32E-WITHFP-NEXT:    li a1, 4
2413 ; ILP32E-WITHFP-NEXT:    sw a1, 12(a0)
2414 ; ILP32E-WITHFP-NEXT:    lw ra, 4(sp) # 4-byte Folded Reload
2415 ; ILP32E-WITHFP-NEXT:    lw s0, 0(sp) # 4-byte Folded Reload
2416 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 8
2417 ; ILP32E-WITHFP-NEXT:    ret
2419 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: callee_large_struct_ret:
2420 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
2421 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 1
2422 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a1, 0(a0)
2423 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 2
2424 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a1, 4(a0)
2425 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 3
2426 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a1, 8(a0)
2427 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    li a1, 4
2428 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    sw a1, 12(a0)
2429 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    ret
2431 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: callee_large_struct_ret:
2432 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
2433 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
2434 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
2435 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
2436 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
2437 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 8
2438 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
2439 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 1
2440 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a1, 0(a0)
2441 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 2
2442 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a1, 4(a0)
2443 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 3
2444 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a1, 8(a0)
2445 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a1, 4
2446 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    sw a1, 12(a0)
2447 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
2448   %a = getelementptr inbounds %struct.large, ptr %agg.result, i32 0, i32 0
2449   store i32 1, ptr %a, align 4
2450   %b = getelementptr inbounds %struct.large, ptr %agg.result, i32 0, i32 1
2451   store i32 2, ptr %b, align 4
2452   %c = getelementptr inbounds %struct.large, ptr %agg.result, i32 0, i32 2
2453   store i32 3, ptr %c, align 4
2454   %d = getelementptr inbounds %struct.large, ptr %agg.result, i32 0, i32 3
2455   store i32 4, ptr %d, align 4
2456   ret void
2459 define i32 @caller_large_struct_ret() {
2460 ; ILP32E-FPELIM-LABEL: caller_large_struct_ret:
2461 ; ILP32E-FPELIM:       # %bb.0:
2462 ; ILP32E-FPELIM-NEXT:    addi sp, sp, -24
2463 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa_offset 24
2464 ; ILP32E-FPELIM-NEXT:    sw ra, 20(sp) # 4-byte Folded Spill
2465 ; ILP32E-FPELIM-NEXT:    sw s0, 16(sp) # 4-byte Folded Spill
2466 ; ILP32E-FPELIM-NEXT:    .cfi_offset ra, -4
2467 ; ILP32E-FPELIM-NEXT:    .cfi_offset s0, -8
2468 ; ILP32E-FPELIM-NEXT:    addi s0, sp, 24
2469 ; ILP32E-FPELIM-NEXT:    .cfi_def_cfa s0, 0
2470 ; ILP32E-FPELIM-NEXT:    andi sp, sp, -8
2471 ; ILP32E-FPELIM-NEXT:    mv a0, sp
2472 ; ILP32E-FPELIM-NEXT:    call callee_large_struct_ret
2473 ; ILP32E-FPELIM-NEXT:    lw a0, 0(sp)
2474 ; ILP32E-FPELIM-NEXT:    lw a1, 12(sp)
2475 ; ILP32E-FPELIM-NEXT:    add a0, a0, a1
2476 ; ILP32E-FPELIM-NEXT:    addi sp, s0, -24
2477 ; ILP32E-FPELIM-NEXT:    lw ra, 20(sp) # 4-byte Folded Reload
2478 ; ILP32E-FPELIM-NEXT:    lw s0, 16(sp) # 4-byte Folded Reload
2479 ; ILP32E-FPELIM-NEXT:    addi sp, sp, 24
2480 ; ILP32E-FPELIM-NEXT:    ret
2482 ; ILP32E-WITHFP-LABEL: caller_large_struct_ret:
2483 ; ILP32E-WITHFP:       # %bb.0:
2484 ; ILP32E-WITHFP-NEXT:    addi sp, sp, -24
2485 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa_offset 24
2486 ; ILP32E-WITHFP-NEXT:    sw ra, 20(sp) # 4-byte Folded Spill
2487 ; ILP32E-WITHFP-NEXT:    sw s0, 16(sp) # 4-byte Folded Spill
2488 ; ILP32E-WITHFP-NEXT:    .cfi_offset ra, -4
2489 ; ILP32E-WITHFP-NEXT:    .cfi_offset s0, -8
2490 ; ILP32E-WITHFP-NEXT:    addi s0, sp, 24
2491 ; ILP32E-WITHFP-NEXT:    .cfi_def_cfa s0, 0
2492 ; ILP32E-WITHFP-NEXT:    andi sp, sp, -8
2493 ; ILP32E-WITHFP-NEXT:    mv a0, sp
2494 ; ILP32E-WITHFP-NEXT:    call callee_large_struct_ret
2495 ; ILP32E-WITHFP-NEXT:    lw a0, 0(sp)
2496 ; ILP32E-WITHFP-NEXT:    lw a1, 12(sp)
2497 ; ILP32E-WITHFP-NEXT:    add a0, a0, a1
2498 ; ILP32E-WITHFP-NEXT:    addi sp, s0, -24
2499 ; ILP32E-WITHFP-NEXT:    lw ra, 20(sp) # 4-byte Folded Reload
2500 ; ILP32E-WITHFP-NEXT:    lw s0, 16(sp) # 4-byte Folded Reload
2501 ; ILP32E-WITHFP-NEXT:    addi sp, sp, 24
2502 ; ILP32E-WITHFP-NEXT:    ret
2504 ; ILP32E-FPELIM-SAVE-RESTORE-LABEL: caller_large_struct_ret:
2505 ; ILP32E-FPELIM-SAVE-RESTORE:       # %bb.0:
2506 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
2507 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, -16
2508 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 24
2509 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
2510 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
2511 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi s0, sp, 24
2512 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
2513 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    andi sp, sp, -8
2514 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    mv a0, sp
2515 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    call callee_large_struct_ret
2516 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a0, 0(sp)
2517 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    lw a1, 12(sp)
2518 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    add a0, a0, a1
2519 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, s0, -24
2520 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    addi sp, sp, 16
2521 ; ILP32E-FPELIM-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
2523 ; ILP32E-WITHFP-SAVE-RESTORE-LABEL: caller_large_struct_ret:
2524 ; ILP32E-WITHFP-SAVE-RESTORE:       # %bb.0:
2525 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call t0, __riscv_save_1
2526 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, -16
2527 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 24
2528 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset ra, -4
2529 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_offset s0, -8
2530 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi s0, sp, 24
2531 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa s0, 0
2532 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    andi sp, sp, -8
2533 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    mv a0, sp
2534 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_large_struct_ret
2535 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a0, 0(sp)
2536 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    lw a1, 12(sp)
2537 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    add a0, a0, a1
2538 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, s0, -24
2539 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, 16
2540 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
2541   %1 = alloca %struct.large
2542   call void @callee_large_struct_ret(ptr sret(%struct.large) %1)
2543   %2 = getelementptr inbounds %struct.large, ptr %1, i32 0, i32 0
2544   %3 = load i32, ptr %2
2545   %4 = getelementptr inbounds %struct.large, ptr %1, i32 0, i32 3
2546   %5 = load i32, ptr %4
2547   %6 = add i32 %3, %5
2548   ret i32 %6