1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck -check-prefixes=CHECK,RV32I %s
4 ; RUN: llc -relocation-model=pic -mtriple=riscv32 -verify-machineinstrs < %s \
5 ; RUN: | FileCheck -check-prefixes=CHECK,RV32I-PIC %s
6 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
7 ; RUN: | FileCheck -check-prefix=RV64I %s
8 ; RUN: llc -code-model=small -mtriple=riscv64 -verify-machineinstrs < %s \
9 ; RUN: | FileCheck -check-prefix=RV64I-SMALL %s
10 ; RUN: llc -code-model=medium -mtriple=riscv64 -verify-machineinstrs < %s \
11 ; RUN: | FileCheck -check-prefix=RV64I-MEDIUM %s
12 ; RUN: llc -code-model=large -mtriple=riscv64 -verify-machineinstrs < %s \
13 ; RUN: | FileCheck -check-prefix=RV64I-LARGE %s
14 ; RUN: llc -code-model=large -mtriple=riscv64 -mattr=experimental-zicfilp -verify-machineinstrs < %s \
15 ; RUN: | FileCheck -check-prefix=RV64I-LARGE-ZICFILP %s
17 declare i32 @external_function(i32)
19 define i32 @test_call_external(i32 %a) nounwind {
20 ; CHECK-LABEL: test_call_external:
22 ; CHECK-NEXT: addi sp, sp, -16
23 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
24 ; CHECK-NEXT: call external_function
25 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
26 ; CHECK-NEXT: addi sp, sp, 16
29 ; RV64I-LABEL: test_call_external:
31 ; RV64I-NEXT: addi sp, sp, -16
32 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
33 ; RV64I-NEXT: call external_function
34 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
35 ; RV64I-NEXT: addi sp, sp, 16
38 ; RV64I-SMALL-LABEL: test_call_external:
39 ; RV64I-SMALL: # %bb.0:
40 ; RV64I-SMALL-NEXT: addi sp, sp, -16
41 ; RV64I-SMALL-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
42 ; RV64I-SMALL-NEXT: call external_function
43 ; RV64I-SMALL-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
44 ; RV64I-SMALL-NEXT: addi sp, sp, 16
45 ; RV64I-SMALL-NEXT: ret
47 ; RV64I-MEDIUM-LABEL: test_call_external:
48 ; RV64I-MEDIUM: # %bb.0:
49 ; RV64I-MEDIUM-NEXT: addi sp, sp, -16
50 ; RV64I-MEDIUM-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
51 ; RV64I-MEDIUM-NEXT: call external_function
52 ; RV64I-MEDIUM-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
53 ; RV64I-MEDIUM-NEXT: addi sp, sp, 16
54 ; RV64I-MEDIUM-NEXT: ret
56 ; RV64I-LARGE-LABEL: test_call_external:
57 ; RV64I-LARGE: # %bb.0:
58 ; RV64I-LARGE-NEXT: addi sp, sp, -16
59 ; RV64I-LARGE-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
60 ; RV64I-LARGE-NEXT: .Lpcrel_hi0:
61 ; RV64I-LARGE-NEXT: auipc a1, %pcrel_hi(.LCPI0_0)
62 ; RV64I-LARGE-NEXT: ld a1, %pcrel_lo(.Lpcrel_hi0)(a1)
63 ; RV64I-LARGE-NEXT: jalr a1
64 ; RV64I-LARGE-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
65 ; RV64I-LARGE-NEXT: addi sp, sp, 16
66 ; RV64I-LARGE-NEXT: ret
68 ; RV64I-LARGE-ZICFILP-LABEL: test_call_external:
69 ; RV64I-LARGE-ZICFILP: # %bb.0:
70 ; RV64I-LARGE-ZICFILP-NEXT: lpad 0
71 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, -16
72 ; RV64I-LARGE-ZICFILP-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
73 ; RV64I-LARGE-ZICFILP-NEXT: .Lpcrel_hi0:
74 ; RV64I-LARGE-ZICFILP-NEXT: auipc a1, %pcrel_hi(.LCPI0_0)
75 ; RV64I-LARGE-ZICFILP-NEXT: ld t2, %pcrel_lo(.Lpcrel_hi0)(a1)
76 ; RV64I-LARGE-ZICFILP-NEXT: jalr t2
77 ; RV64I-LARGE-ZICFILP-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
78 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, 16
79 ; RV64I-LARGE-ZICFILP-NEXT: ret
80 %1 = call i32 @external_function(i32 %a)
84 declare dso_local i32 @dso_local_function(i32)
86 define i32 @test_call_dso_local(i32 %a) nounwind {
87 ; CHECK-LABEL: test_call_dso_local:
89 ; CHECK-NEXT: addi sp, sp, -16
90 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
91 ; CHECK-NEXT: call dso_local_function
92 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
93 ; CHECK-NEXT: addi sp, sp, 16
96 ; RV64I-LABEL: test_call_dso_local:
98 ; RV64I-NEXT: addi sp, sp, -16
99 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
100 ; RV64I-NEXT: call dso_local_function
101 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
102 ; RV64I-NEXT: addi sp, sp, 16
105 ; RV64I-SMALL-LABEL: test_call_dso_local:
106 ; RV64I-SMALL: # %bb.0:
107 ; RV64I-SMALL-NEXT: addi sp, sp, -16
108 ; RV64I-SMALL-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
109 ; RV64I-SMALL-NEXT: call dso_local_function
110 ; RV64I-SMALL-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
111 ; RV64I-SMALL-NEXT: addi sp, sp, 16
112 ; RV64I-SMALL-NEXT: ret
114 ; RV64I-MEDIUM-LABEL: test_call_dso_local:
115 ; RV64I-MEDIUM: # %bb.0:
116 ; RV64I-MEDIUM-NEXT: addi sp, sp, -16
117 ; RV64I-MEDIUM-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
118 ; RV64I-MEDIUM-NEXT: call dso_local_function
119 ; RV64I-MEDIUM-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
120 ; RV64I-MEDIUM-NEXT: addi sp, sp, 16
121 ; RV64I-MEDIUM-NEXT: ret
123 ; RV64I-LARGE-LABEL: test_call_dso_local:
124 ; RV64I-LARGE: # %bb.0:
125 ; RV64I-LARGE-NEXT: addi sp, sp, -16
126 ; RV64I-LARGE-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
127 ; RV64I-LARGE-NEXT: .Lpcrel_hi1:
128 ; RV64I-LARGE-NEXT: auipc a1, %pcrel_hi(.LCPI1_0)
129 ; RV64I-LARGE-NEXT: ld a1, %pcrel_lo(.Lpcrel_hi1)(a1)
130 ; RV64I-LARGE-NEXT: jalr a1
131 ; RV64I-LARGE-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
132 ; RV64I-LARGE-NEXT: addi sp, sp, 16
133 ; RV64I-LARGE-NEXT: ret
135 ; RV64I-LARGE-ZICFILP-LABEL: test_call_dso_local:
136 ; RV64I-LARGE-ZICFILP: # %bb.0:
137 ; RV64I-LARGE-ZICFILP-NEXT: lpad 0
138 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, -16
139 ; RV64I-LARGE-ZICFILP-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
140 ; RV64I-LARGE-ZICFILP-NEXT: .Lpcrel_hi1:
141 ; RV64I-LARGE-ZICFILP-NEXT: auipc a1, %pcrel_hi(.LCPI1_0)
142 ; RV64I-LARGE-ZICFILP-NEXT: ld t2, %pcrel_lo(.Lpcrel_hi1)(a1)
143 ; RV64I-LARGE-ZICFILP-NEXT: jalr t2
144 ; RV64I-LARGE-ZICFILP-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
145 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, 16
146 ; RV64I-LARGE-ZICFILP-NEXT: ret
147 %1 = call i32 @dso_local_function(i32 %a)
151 define i32 @defined_function(i32 %a) nounwind {
152 ; CHECK-LABEL: defined_function:
154 ; CHECK-NEXT: addi a0, a0, 1
157 ; RV64I-LABEL: defined_function:
159 ; RV64I-NEXT: addiw a0, a0, 1
162 ; RV64I-SMALL-LABEL: defined_function:
163 ; RV64I-SMALL: # %bb.0:
164 ; RV64I-SMALL-NEXT: addiw a0, a0, 1
165 ; RV64I-SMALL-NEXT: ret
167 ; RV64I-MEDIUM-LABEL: defined_function:
168 ; RV64I-MEDIUM: # %bb.0:
169 ; RV64I-MEDIUM-NEXT: addiw a0, a0, 1
170 ; RV64I-MEDIUM-NEXT: ret
172 ; RV64I-LARGE-LABEL: defined_function:
173 ; RV64I-LARGE: # %bb.0:
174 ; RV64I-LARGE-NEXT: addiw a0, a0, 1
175 ; RV64I-LARGE-NEXT: ret
177 ; RV64I-LARGE-ZICFILP-LABEL: defined_function:
178 ; RV64I-LARGE-ZICFILP: # %bb.0:
179 ; RV64I-LARGE-ZICFILP-NEXT: lpad 0
180 ; RV64I-LARGE-ZICFILP-NEXT: addiw a0, a0, 1
181 ; RV64I-LARGE-ZICFILP-NEXT: ret
186 define i32 @test_call_defined(i32 %a) nounwind {
187 ; CHECK-LABEL: test_call_defined:
189 ; CHECK-NEXT: addi sp, sp, -16
190 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
191 ; CHECK-NEXT: call defined_function
192 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
193 ; CHECK-NEXT: addi sp, sp, 16
196 ; RV64I-LABEL: test_call_defined:
198 ; RV64I-NEXT: addi sp, sp, -16
199 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
200 ; RV64I-NEXT: call defined_function
201 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
202 ; RV64I-NEXT: addi sp, sp, 16
205 ; RV64I-SMALL-LABEL: test_call_defined:
206 ; RV64I-SMALL: # %bb.0:
207 ; RV64I-SMALL-NEXT: addi sp, sp, -16
208 ; RV64I-SMALL-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
209 ; RV64I-SMALL-NEXT: call defined_function
210 ; RV64I-SMALL-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
211 ; RV64I-SMALL-NEXT: addi sp, sp, 16
212 ; RV64I-SMALL-NEXT: ret
214 ; RV64I-MEDIUM-LABEL: test_call_defined:
215 ; RV64I-MEDIUM: # %bb.0:
216 ; RV64I-MEDIUM-NEXT: addi sp, sp, -16
217 ; RV64I-MEDIUM-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
218 ; RV64I-MEDIUM-NEXT: call defined_function
219 ; RV64I-MEDIUM-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
220 ; RV64I-MEDIUM-NEXT: addi sp, sp, 16
221 ; RV64I-MEDIUM-NEXT: ret
223 ; RV64I-LARGE-LABEL: test_call_defined:
224 ; RV64I-LARGE: # %bb.0:
225 ; RV64I-LARGE-NEXT: addi sp, sp, -16
226 ; RV64I-LARGE-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
227 ; RV64I-LARGE-NEXT: .Lpcrel_hi2:
228 ; RV64I-LARGE-NEXT: auipc a1, %pcrel_hi(.LCPI3_0)
229 ; RV64I-LARGE-NEXT: ld a1, %pcrel_lo(.Lpcrel_hi2)(a1)
230 ; RV64I-LARGE-NEXT: jalr a1
231 ; RV64I-LARGE-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
232 ; RV64I-LARGE-NEXT: addi sp, sp, 16
233 ; RV64I-LARGE-NEXT: ret
235 ; RV64I-LARGE-ZICFILP-LABEL: test_call_defined:
236 ; RV64I-LARGE-ZICFILP: # %bb.0:
237 ; RV64I-LARGE-ZICFILP-NEXT: lpad 0
238 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, -16
239 ; RV64I-LARGE-ZICFILP-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
240 ; RV64I-LARGE-ZICFILP-NEXT: .Lpcrel_hi2:
241 ; RV64I-LARGE-ZICFILP-NEXT: auipc a1, %pcrel_hi(.LCPI3_0)
242 ; RV64I-LARGE-ZICFILP-NEXT: ld t2, %pcrel_lo(.Lpcrel_hi2)(a1)
243 ; RV64I-LARGE-ZICFILP-NEXT: jalr t2
244 ; RV64I-LARGE-ZICFILP-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
245 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, 16
246 ; RV64I-LARGE-ZICFILP-NEXT: ret
247 %1 = call i32 @defined_function(i32 %a)
251 define i32 @test_call_indirect(ptr %a, i32 %b) nounwind {
252 ; CHECK-LABEL: test_call_indirect:
254 ; CHECK-NEXT: addi sp, sp, -16
255 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
256 ; CHECK-NEXT: mv a2, a0
257 ; CHECK-NEXT: mv a0, a1
258 ; CHECK-NEXT: jalr a2
259 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
260 ; CHECK-NEXT: addi sp, sp, 16
263 ; RV64I-LABEL: test_call_indirect:
265 ; RV64I-NEXT: addi sp, sp, -16
266 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
267 ; RV64I-NEXT: mv a2, a0
268 ; RV64I-NEXT: mv a0, a1
269 ; RV64I-NEXT: jalr a2
270 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
271 ; RV64I-NEXT: addi sp, sp, 16
274 ; RV64I-SMALL-LABEL: test_call_indirect:
275 ; RV64I-SMALL: # %bb.0:
276 ; RV64I-SMALL-NEXT: addi sp, sp, -16
277 ; RV64I-SMALL-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
278 ; RV64I-SMALL-NEXT: mv a2, a0
279 ; RV64I-SMALL-NEXT: mv a0, a1
280 ; RV64I-SMALL-NEXT: jalr a2
281 ; RV64I-SMALL-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
282 ; RV64I-SMALL-NEXT: addi sp, sp, 16
283 ; RV64I-SMALL-NEXT: ret
285 ; RV64I-MEDIUM-LABEL: test_call_indirect:
286 ; RV64I-MEDIUM: # %bb.0:
287 ; RV64I-MEDIUM-NEXT: addi sp, sp, -16
288 ; RV64I-MEDIUM-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
289 ; RV64I-MEDIUM-NEXT: mv a2, a0
290 ; RV64I-MEDIUM-NEXT: mv a0, a1
291 ; RV64I-MEDIUM-NEXT: jalr a2
292 ; RV64I-MEDIUM-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
293 ; RV64I-MEDIUM-NEXT: addi sp, sp, 16
294 ; RV64I-MEDIUM-NEXT: ret
296 ; RV64I-LARGE-LABEL: test_call_indirect:
297 ; RV64I-LARGE: # %bb.0:
298 ; RV64I-LARGE-NEXT: addi sp, sp, -16
299 ; RV64I-LARGE-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
300 ; RV64I-LARGE-NEXT: mv a2, a0
301 ; RV64I-LARGE-NEXT: mv a0, a1
302 ; RV64I-LARGE-NEXT: jalr a2
303 ; RV64I-LARGE-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
304 ; RV64I-LARGE-NEXT: addi sp, sp, 16
305 ; RV64I-LARGE-NEXT: ret
307 ; RV64I-LARGE-ZICFILP-LABEL: test_call_indirect:
308 ; RV64I-LARGE-ZICFILP: # %bb.0:
309 ; RV64I-LARGE-ZICFILP-NEXT: lpad 0
310 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, -16
311 ; RV64I-LARGE-ZICFILP-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
312 ; RV64I-LARGE-ZICFILP-NEXT: mv a2, a0
313 ; RV64I-LARGE-ZICFILP-NEXT: mv a0, a1
314 ; RV64I-LARGE-ZICFILP-NEXT: jalr a2
315 ; RV64I-LARGE-ZICFILP-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
316 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, 16
317 ; RV64I-LARGE-ZICFILP-NEXT: ret
318 %1 = call i32 %a(i32 %b)
322 ; Make sure we don't use t0 as the source for jalr as that is a hint to pop the
323 ; return address stack on some microarchitectures.
324 define i32 @test_call_indirect_no_t0(ptr %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h) nounwind {
325 ; CHECK-LABEL: test_call_indirect_no_t0:
327 ; CHECK-NEXT: addi sp, sp, -16
328 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
329 ; CHECK-NEXT: mv t1, a0
330 ; CHECK-NEXT: mv a0, a1
331 ; CHECK-NEXT: mv a1, a2
332 ; CHECK-NEXT: mv a2, a3
333 ; CHECK-NEXT: mv a3, a4
334 ; CHECK-NEXT: mv a4, a5
335 ; CHECK-NEXT: mv a5, a6
336 ; CHECK-NEXT: mv a6, a7
337 ; CHECK-NEXT: jalr t1
338 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
339 ; CHECK-NEXT: addi sp, sp, 16
342 ; RV64I-LABEL: test_call_indirect_no_t0:
344 ; RV64I-NEXT: addi sp, sp, -16
345 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
346 ; RV64I-NEXT: mv t1, a0
347 ; RV64I-NEXT: mv a0, a1
348 ; RV64I-NEXT: mv a1, a2
349 ; RV64I-NEXT: mv a2, a3
350 ; RV64I-NEXT: mv a3, a4
351 ; RV64I-NEXT: mv a4, a5
352 ; RV64I-NEXT: mv a5, a6
353 ; RV64I-NEXT: mv a6, a7
354 ; RV64I-NEXT: jalr t1
355 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
356 ; RV64I-NEXT: addi sp, sp, 16
359 ; RV64I-SMALL-LABEL: test_call_indirect_no_t0:
360 ; RV64I-SMALL: # %bb.0:
361 ; RV64I-SMALL-NEXT: addi sp, sp, -16
362 ; RV64I-SMALL-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
363 ; RV64I-SMALL-NEXT: mv t1, a0
364 ; RV64I-SMALL-NEXT: mv a0, a1
365 ; RV64I-SMALL-NEXT: mv a1, a2
366 ; RV64I-SMALL-NEXT: mv a2, a3
367 ; RV64I-SMALL-NEXT: mv a3, a4
368 ; RV64I-SMALL-NEXT: mv a4, a5
369 ; RV64I-SMALL-NEXT: mv a5, a6
370 ; RV64I-SMALL-NEXT: mv a6, a7
371 ; RV64I-SMALL-NEXT: jalr t1
372 ; RV64I-SMALL-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
373 ; RV64I-SMALL-NEXT: addi sp, sp, 16
374 ; RV64I-SMALL-NEXT: ret
376 ; RV64I-MEDIUM-LABEL: test_call_indirect_no_t0:
377 ; RV64I-MEDIUM: # %bb.0:
378 ; RV64I-MEDIUM-NEXT: addi sp, sp, -16
379 ; RV64I-MEDIUM-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
380 ; RV64I-MEDIUM-NEXT: mv t1, a0
381 ; RV64I-MEDIUM-NEXT: mv a0, a1
382 ; RV64I-MEDIUM-NEXT: mv a1, a2
383 ; RV64I-MEDIUM-NEXT: mv a2, a3
384 ; RV64I-MEDIUM-NEXT: mv a3, a4
385 ; RV64I-MEDIUM-NEXT: mv a4, a5
386 ; RV64I-MEDIUM-NEXT: mv a5, a6
387 ; RV64I-MEDIUM-NEXT: mv a6, a7
388 ; RV64I-MEDIUM-NEXT: jalr t1
389 ; RV64I-MEDIUM-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
390 ; RV64I-MEDIUM-NEXT: addi sp, sp, 16
391 ; RV64I-MEDIUM-NEXT: ret
393 ; RV64I-LARGE-LABEL: test_call_indirect_no_t0:
394 ; RV64I-LARGE: # %bb.0:
395 ; RV64I-LARGE-NEXT: addi sp, sp, -16
396 ; RV64I-LARGE-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
397 ; RV64I-LARGE-NEXT: mv t1, a0
398 ; RV64I-LARGE-NEXT: mv a0, a1
399 ; RV64I-LARGE-NEXT: mv a1, a2
400 ; RV64I-LARGE-NEXT: mv a2, a3
401 ; RV64I-LARGE-NEXT: mv a3, a4
402 ; RV64I-LARGE-NEXT: mv a4, a5
403 ; RV64I-LARGE-NEXT: mv a5, a6
404 ; RV64I-LARGE-NEXT: mv a6, a7
405 ; RV64I-LARGE-NEXT: jalr t1
406 ; RV64I-LARGE-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
407 ; RV64I-LARGE-NEXT: addi sp, sp, 16
408 ; RV64I-LARGE-NEXT: ret
410 ; RV64I-LARGE-ZICFILP-LABEL: test_call_indirect_no_t0:
411 ; RV64I-LARGE-ZICFILP: # %bb.0:
412 ; RV64I-LARGE-ZICFILP-NEXT: lpad 0
413 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, -16
414 ; RV64I-LARGE-ZICFILP-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
415 ; RV64I-LARGE-ZICFILP-NEXT: mv t1, a0
416 ; RV64I-LARGE-ZICFILP-NEXT: mv a0, a1
417 ; RV64I-LARGE-ZICFILP-NEXT: mv a1, a2
418 ; RV64I-LARGE-ZICFILP-NEXT: mv a2, a3
419 ; RV64I-LARGE-ZICFILP-NEXT: mv a3, a4
420 ; RV64I-LARGE-ZICFILP-NEXT: mv a4, a5
421 ; RV64I-LARGE-ZICFILP-NEXT: mv a5, a6
422 ; RV64I-LARGE-ZICFILP-NEXT: mv a6, a7
423 ; RV64I-LARGE-ZICFILP-NEXT: jalr t1
424 ; RV64I-LARGE-ZICFILP-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
425 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, 16
426 ; RV64I-LARGE-ZICFILP-NEXT: ret
427 %1 = call i32 %a(i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h)
431 ; Ensure that calls to fastcc functions aren't rejected. Such calls may be
432 ; introduced when compiling with optimisation.
434 define fastcc i32 @fastcc_function(i32 %a, i32 %b) nounwind {
435 ; CHECK-LABEL: fastcc_function:
437 ; CHECK-NEXT: add a0, a0, a1
440 ; RV64I-LABEL: fastcc_function:
442 ; RV64I-NEXT: addw a0, a0, a1
445 ; RV64I-SMALL-LABEL: fastcc_function:
446 ; RV64I-SMALL: # %bb.0:
447 ; RV64I-SMALL-NEXT: addw a0, a0, a1
448 ; RV64I-SMALL-NEXT: ret
450 ; RV64I-MEDIUM-LABEL: fastcc_function:
451 ; RV64I-MEDIUM: # %bb.0:
452 ; RV64I-MEDIUM-NEXT: addw a0, a0, a1
453 ; RV64I-MEDIUM-NEXT: ret
455 ; RV64I-LARGE-LABEL: fastcc_function:
456 ; RV64I-LARGE: # %bb.0:
457 ; RV64I-LARGE-NEXT: addw a0, a0, a1
458 ; RV64I-LARGE-NEXT: ret
460 ; RV64I-LARGE-ZICFILP-LABEL: fastcc_function:
461 ; RV64I-LARGE-ZICFILP: # %bb.0:
462 ; RV64I-LARGE-ZICFILP-NEXT: lpad 0
463 ; RV64I-LARGE-ZICFILP-NEXT: addw a0, a0, a1
464 ; RV64I-LARGE-ZICFILP-NEXT: ret
469 define i32 @test_call_fastcc(i32 %a, i32 %b) nounwind {
470 ; CHECK-LABEL: test_call_fastcc:
472 ; CHECK-NEXT: addi sp, sp, -16
473 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
474 ; CHECK-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
475 ; CHECK-NEXT: mv s0, a0
476 ; CHECK-NEXT: call fastcc_function
477 ; CHECK-NEXT: mv a0, s0
478 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
479 ; CHECK-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
480 ; CHECK-NEXT: addi sp, sp, 16
483 ; RV64I-LABEL: test_call_fastcc:
485 ; RV64I-NEXT: addi sp, sp, -16
486 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
487 ; RV64I-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
488 ; RV64I-NEXT: mv s0, a0
489 ; RV64I-NEXT: call fastcc_function
490 ; RV64I-NEXT: mv a0, s0
491 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
492 ; RV64I-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
493 ; RV64I-NEXT: addi sp, sp, 16
496 ; RV64I-SMALL-LABEL: test_call_fastcc:
497 ; RV64I-SMALL: # %bb.0:
498 ; RV64I-SMALL-NEXT: addi sp, sp, -16
499 ; RV64I-SMALL-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
500 ; RV64I-SMALL-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
501 ; RV64I-SMALL-NEXT: mv s0, a0
502 ; RV64I-SMALL-NEXT: call fastcc_function
503 ; RV64I-SMALL-NEXT: mv a0, s0
504 ; RV64I-SMALL-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
505 ; RV64I-SMALL-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
506 ; RV64I-SMALL-NEXT: addi sp, sp, 16
507 ; RV64I-SMALL-NEXT: ret
509 ; RV64I-MEDIUM-LABEL: test_call_fastcc:
510 ; RV64I-MEDIUM: # %bb.0:
511 ; RV64I-MEDIUM-NEXT: addi sp, sp, -16
512 ; RV64I-MEDIUM-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
513 ; RV64I-MEDIUM-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
514 ; RV64I-MEDIUM-NEXT: mv s0, a0
515 ; RV64I-MEDIUM-NEXT: call fastcc_function
516 ; RV64I-MEDIUM-NEXT: mv a0, s0
517 ; RV64I-MEDIUM-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
518 ; RV64I-MEDIUM-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
519 ; RV64I-MEDIUM-NEXT: addi sp, sp, 16
520 ; RV64I-MEDIUM-NEXT: ret
522 ; RV64I-LARGE-LABEL: test_call_fastcc:
523 ; RV64I-LARGE: # %bb.0:
524 ; RV64I-LARGE-NEXT: addi sp, sp, -16
525 ; RV64I-LARGE-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
526 ; RV64I-LARGE-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
527 ; RV64I-LARGE-NEXT: mv s0, a0
528 ; RV64I-LARGE-NEXT: .Lpcrel_hi3:
529 ; RV64I-LARGE-NEXT: auipc a0, %pcrel_hi(.LCPI7_0)
530 ; RV64I-LARGE-NEXT: ld a2, %pcrel_lo(.Lpcrel_hi3)(a0)
531 ; RV64I-LARGE-NEXT: mv a0, s0
532 ; RV64I-LARGE-NEXT: jalr a2
533 ; RV64I-LARGE-NEXT: mv a0, s0
534 ; RV64I-LARGE-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
535 ; RV64I-LARGE-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
536 ; RV64I-LARGE-NEXT: addi sp, sp, 16
537 ; RV64I-LARGE-NEXT: ret
539 ; RV64I-LARGE-ZICFILP-LABEL: test_call_fastcc:
540 ; RV64I-LARGE-ZICFILP: # %bb.0:
541 ; RV64I-LARGE-ZICFILP-NEXT: lpad 0
542 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, -16
543 ; RV64I-LARGE-ZICFILP-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
544 ; RV64I-LARGE-ZICFILP-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
545 ; RV64I-LARGE-ZICFILP-NEXT: mv s0, a0
546 ; RV64I-LARGE-ZICFILP-NEXT: .Lpcrel_hi3:
547 ; RV64I-LARGE-ZICFILP-NEXT: auipc a0, %pcrel_hi(.LCPI7_0)
548 ; RV64I-LARGE-ZICFILP-NEXT: ld t2, %pcrel_lo(.Lpcrel_hi3)(a0)
549 ; RV64I-LARGE-ZICFILP-NEXT: mv a0, s0
550 ; RV64I-LARGE-ZICFILP-NEXT: jalr t2
551 ; RV64I-LARGE-ZICFILP-NEXT: mv a0, s0
552 ; RV64I-LARGE-ZICFILP-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
553 ; RV64I-LARGE-ZICFILP-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
554 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, 16
555 ; RV64I-LARGE-ZICFILP-NEXT: ret
556 %1 = call fastcc i32 @fastcc_function(i32 %a, i32 %b)
560 declare i32 @external_many_args(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) nounwind
562 define i32 @test_call_external_many_args(i32 %a) nounwind {
563 ; CHECK-LABEL: test_call_external_many_args:
565 ; CHECK-NEXT: addi sp, sp, -16
566 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
567 ; CHECK-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
568 ; CHECK-NEXT: mv s0, a0
569 ; CHECK-NEXT: sw a0, 0(sp)
570 ; CHECK-NEXT: sw a0, 4(sp)
571 ; CHECK-NEXT: mv a1, a0
572 ; CHECK-NEXT: mv a2, a0
573 ; CHECK-NEXT: mv a3, a0
574 ; CHECK-NEXT: mv a4, a0
575 ; CHECK-NEXT: mv a5, a0
576 ; CHECK-NEXT: mv a6, a0
577 ; CHECK-NEXT: mv a7, a0
578 ; CHECK-NEXT: call external_many_args
579 ; CHECK-NEXT: mv a0, s0
580 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
581 ; CHECK-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
582 ; CHECK-NEXT: addi sp, sp, 16
585 ; RV64I-LABEL: test_call_external_many_args:
587 ; RV64I-NEXT: addi sp, sp, -32
588 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
589 ; RV64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
590 ; RV64I-NEXT: mv s0, a0
591 ; RV64I-NEXT: sd a0, 0(sp)
592 ; RV64I-NEXT: sd a0, 8(sp)
593 ; RV64I-NEXT: mv a1, a0
594 ; RV64I-NEXT: mv a2, a0
595 ; RV64I-NEXT: mv a3, a0
596 ; RV64I-NEXT: mv a4, a0
597 ; RV64I-NEXT: mv a5, a0
598 ; RV64I-NEXT: mv a6, a0
599 ; RV64I-NEXT: mv a7, a0
600 ; RV64I-NEXT: call external_many_args
601 ; RV64I-NEXT: mv a0, s0
602 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
603 ; RV64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
604 ; RV64I-NEXT: addi sp, sp, 32
607 ; RV64I-SMALL-LABEL: test_call_external_many_args:
608 ; RV64I-SMALL: # %bb.0:
609 ; RV64I-SMALL-NEXT: addi sp, sp, -32
610 ; RV64I-SMALL-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
611 ; RV64I-SMALL-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
612 ; RV64I-SMALL-NEXT: mv s0, a0
613 ; RV64I-SMALL-NEXT: sd a0, 0(sp)
614 ; RV64I-SMALL-NEXT: sd a0, 8(sp)
615 ; RV64I-SMALL-NEXT: mv a1, a0
616 ; RV64I-SMALL-NEXT: mv a2, a0
617 ; RV64I-SMALL-NEXT: mv a3, a0
618 ; RV64I-SMALL-NEXT: mv a4, a0
619 ; RV64I-SMALL-NEXT: mv a5, a0
620 ; RV64I-SMALL-NEXT: mv a6, a0
621 ; RV64I-SMALL-NEXT: mv a7, a0
622 ; RV64I-SMALL-NEXT: call external_many_args
623 ; RV64I-SMALL-NEXT: mv a0, s0
624 ; RV64I-SMALL-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
625 ; RV64I-SMALL-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
626 ; RV64I-SMALL-NEXT: addi sp, sp, 32
627 ; RV64I-SMALL-NEXT: ret
629 ; RV64I-MEDIUM-LABEL: test_call_external_many_args:
630 ; RV64I-MEDIUM: # %bb.0:
631 ; RV64I-MEDIUM-NEXT: addi sp, sp, -32
632 ; RV64I-MEDIUM-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
633 ; RV64I-MEDIUM-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
634 ; RV64I-MEDIUM-NEXT: mv s0, a0
635 ; RV64I-MEDIUM-NEXT: sd a0, 0(sp)
636 ; RV64I-MEDIUM-NEXT: sd a0, 8(sp)
637 ; RV64I-MEDIUM-NEXT: mv a1, a0
638 ; RV64I-MEDIUM-NEXT: mv a2, a0
639 ; RV64I-MEDIUM-NEXT: mv a3, a0
640 ; RV64I-MEDIUM-NEXT: mv a4, a0
641 ; RV64I-MEDIUM-NEXT: mv a5, a0
642 ; RV64I-MEDIUM-NEXT: mv a6, a0
643 ; RV64I-MEDIUM-NEXT: mv a7, a0
644 ; RV64I-MEDIUM-NEXT: call external_many_args
645 ; RV64I-MEDIUM-NEXT: mv a0, s0
646 ; RV64I-MEDIUM-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
647 ; RV64I-MEDIUM-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
648 ; RV64I-MEDIUM-NEXT: addi sp, sp, 32
649 ; RV64I-MEDIUM-NEXT: ret
651 ; RV64I-LARGE-LABEL: test_call_external_many_args:
652 ; RV64I-LARGE: # %bb.0:
653 ; RV64I-LARGE-NEXT: addi sp, sp, -32
654 ; RV64I-LARGE-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
655 ; RV64I-LARGE-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
656 ; RV64I-LARGE-NEXT: mv s0, a0
657 ; RV64I-LARGE-NEXT: .Lpcrel_hi4:
658 ; RV64I-LARGE-NEXT: auipc a0, %pcrel_hi(.LCPI8_0)
659 ; RV64I-LARGE-NEXT: ld t1, %pcrel_lo(.Lpcrel_hi4)(a0)
660 ; RV64I-LARGE-NEXT: sd s0, 0(sp)
661 ; RV64I-LARGE-NEXT: sd s0, 8(sp)
662 ; RV64I-LARGE-NEXT: mv a0, s0
663 ; RV64I-LARGE-NEXT: mv a1, s0
664 ; RV64I-LARGE-NEXT: mv a2, s0
665 ; RV64I-LARGE-NEXT: mv a3, s0
666 ; RV64I-LARGE-NEXT: mv a4, s0
667 ; RV64I-LARGE-NEXT: mv a5, s0
668 ; RV64I-LARGE-NEXT: mv a6, s0
669 ; RV64I-LARGE-NEXT: mv a7, s0
670 ; RV64I-LARGE-NEXT: jalr t1
671 ; RV64I-LARGE-NEXT: mv a0, s0
672 ; RV64I-LARGE-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
673 ; RV64I-LARGE-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
674 ; RV64I-LARGE-NEXT: addi sp, sp, 32
675 ; RV64I-LARGE-NEXT: ret
677 ; RV64I-LARGE-ZICFILP-LABEL: test_call_external_many_args:
678 ; RV64I-LARGE-ZICFILP: # %bb.0:
679 ; RV64I-LARGE-ZICFILP-NEXT: lpad 0
680 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, -32
681 ; RV64I-LARGE-ZICFILP-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
682 ; RV64I-LARGE-ZICFILP-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
683 ; RV64I-LARGE-ZICFILP-NEXT: mv s0, a0
684 ; RV64I-LARGE-ZICFILP-NEXT: .Lpcrel_hi4:
685 ; RV64I-LARGE-ZICFILP-NEXT: auipc a0, %pcrel_hi(.LCPI8_0)
686 ; RV64I-LARGE-ZICFILP-NEXT: ld t2, %pcrel_lo(.Lpcrel_hi4)(a0)
687 ; RV64I-LARGE-ZICFILP-NEXT: sd s0, 0(sp)
688 ; RV64I-LARGE-ZICFILP-NEXT: sd s0, 8(sp)
689 ; RV64I-LARGE-ZICFILP-NEXT: mv a0, s0
690 ; RV64I-LARGE-ZICFILP-NEXT: mv a1, s0
691 ; RV64I-LARGE-ZICFILP-NEXT: mv a2, s0
692 ; RV64I-LARGE-ZICFILP-NEXT: mv a3, s0
693 ; RV64I-LARGE-ZICFILP-NEXT: mv a4, s0
694 ; RV64I-LARGE-ZICFILP-NEXT: mv a5, s0
695 ; RV64I-LARGE-ZICFILP-NEXT: mv a6, s0
696 ; RV64I-LARGE-ZICFILP-NEXT: mv a7, s0
697 ; RV64I-LARGE-ZICFILP-NEXT: jalr t2
698 ; RV64I-LARGE-ZICFILP-NEXT: mv a0, s0
699 ; RV64I-LARGE-ZICFILP-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
700 ; RV64I-LARGE-ZICFILP-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
701 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, 32
702 ; RV64I-LARGE-ZICFILP-NEXT: ret
703 %1 = call i32 @external_many_args(i32 %a, i32 %a, i32 %a, i32 %a, i32 %a,
704 i32 %a, i32 %a, i32 %a, i32 %a, i32 %a)
708 define i32 @defined_many_args(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 %j) nounwind {
709 ; CHECK-LABEL: defined_many_args:
711 ; CHECK-NEXT: lw a0, 4(sp)
712 ; CHECK-NEXT: addi a0, a0, 1
715 ; RV64I-LABEL: defined_many_args:
717 ; RV64I-NEXT: lw a0, 8(sp)
718 ; RV64I-NEXT: addiw a0, a0, 1
721 ; RV64I-SMALL-LABEL: defined_many_args:
722 ; RV64I-SMALL: # %bb.0:
723 ; RV64I-SMALL-NEXT: lw a0, 8(sp)
724 ; RV64I-SMALL-NEXT: addiw a0, a0, 1
725 ; RV64I-SMALL-NEXT: ret
727 ; RV64I-MEDIUM-LABEL: defined_many_args:
728 ; RV64I-MEDIUM: # %bb.0:
729 ; RV64I-MEDIUM-NEXT: lw a0, 8(sp)
730 ; RV64I-MEDIUM-NEXT: addiw a0, a0, 1
731 ; RV64I-MEDIUM-NEXT: ret
733 ; RV64I-LARGE-LABEL: defined_many_args:
734 ; RV64I-LARGE: # %bb.0:
735 ; RV64I-LARGE-NEXT: lw a0, 8(sp)
736 ; RV64I-LARGE-NEXT: addiw a0, a0, 1
737 ; RV64I-LARGE-NEXT: ret
739 ; RV64I-LARGE-ZICFILP-LABEL: defined_many_args:
740 ; RV64I-LARGE-ZICFILP: # %bb.0:
741 ; RV64I-LARGE-ZICFILP-NEXT: lpad 0
742 ; RV64I-LARGE-ZICFILP-NEXT: lw a0, 8(sp)
743 ; RV64I-LARGE-ZICFILP-NEXT: addiw a0, a0, 1
744 ; RV64I-LARGE-ZICFILP-NEXT: ret
745 %added = add i32 %j, 1
749 define i32 @test_call_defined_many_args(i32 %a) nounwind {
750 ; CHECK-LABEL: test_call_defined_many_args:
752 ; CHECK-NEXT: addi sp, sp, -16
753 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
754 ; CHECK-NEXT: sw a0, 0(sp)
755 ; CHECK-NEXT: sw a0, 4(sp)
756 ; CHECK-NEXT: mv a1, a0
757 ; CHECK-NEXT: mv a2, a0
758 ; CHECK-NEXT: mv a3, a0
759 ; CHECK-NEXT: mv a4, a0
760 ; CHECK-NEXT: mv a5, a0
761 ; CHECK-NEXT: mv a6, a0
762 ; CHECK-NEXT: mv a7, a0
763 ; CHECK-NEXT: call defined_many_args
764 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
765 ; CHECK-NEXT: addi sp, sp, 16
768 ; RV64I-LABEL: test_call_defined_many_args:
770 ; RV64I-NEXT: addi sp, sp, -32
771 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
772 ; RV64I-NEXT: sd a0, 0(sp)
773 ; RV64I-NEXT: sd a0, 8(sp)
774 ; RV64I-NEXT: mv a1, a0
775 ; RV64I-NEXT: mv a2, a0
776 ; RV64I-NEXT: mv a3, a0
777 ; RV64I-NEXT: mv a4, a0
778 ; RV64I-NEXT: mv a5, a0
779 ; RV64I-NEXT: mv a6, a0
780 ; RV64I-NEXT: mv a7, a0
781 ; RV64I-NEXT: call defined_many_args
782 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
783 ; RV64I-NEXT: addi sp, sp, 32
786 ; RV64I-SMALL-LABEL: test_call_defined_many_args:
787 ; RV64I-SMALL: # %bb.0:
788 ; RV64I-SMALL-NEXT: addi sp, sp, -32
789 ; RV64I-SMALL-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
790 ; RV64I-SMALL-NEXT: sd a0, 0(sp)
791 ; RV64I-SMALL-NEXT: sd a0, 8(sp)
792 ; RV64I-SMALL-NEXT: mv a1, a0
793 ; RV64I-SMALL-NEXT: mv a2, a0
794 ; RV64I-SMALL-NEXT: mv a3, a0
795 ; RV64I-SMALL-NEXT: mv a4, a0
796 ; RV64I-SMALL-NEXT: mv a5, a0
797 ; RV64I-SMALL-NEXT: mv a6, a0
798 ; RV64I-SMALL-NEXT: mv a7, a0
799 ; RV64I-SMALL-NEXT: call defined_many_args
800 ; RV64I-SMALL-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
801 ; RV64I-SMALL-NEXT: addi sp, sp, 32
802 ; RV64I-SMALL-NEXT: ret
804 ; RV64I-MEDIUM-LABEL: test_call_defined_many_args:
805 ; RV64I-MEDIUM: # %bb.0:
806 ; RV64I-MEDIUM-NEXT: addi sp, sp, -32
807 ; RV64I-MEDIUM-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
808 ; RV64I-MEDIUM-NEXT: sd a0, 0(sp)
809 ; RV64I-MEDIUM-NEXT: sd a0, 8(sp)
810 ; RV64I-MEDIUM-NEXT: mv a1, a0
811 ; RV64I-MEDIUM-NEXT: mv a2, a0
812 ; RV64I-MEDIUM-NEXT: mv a3, a0
813 ; RV64I-MEDIUM-NEXT: mv a4, a0
814 ; RV64I-MEDIUM-NEXT: mv a5, a0
815 ; RV64I-MEDIUM-NEXT: mv a6, a0
816 ; RV64I-MEDIUM-NEXT: mv a7, a0
817 ; RV64I-MEDIUM-NEXT: call defined_many_args
818 ; RV64I-MEDIUM-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
819 ; RV64I-MEDIUM-NEXT: addi sp, sp, 32
820 ; RV64I-MEDIUM-NEXT: ret
822 ; RV64I-LARGE-LABEL: test_call_defined_many_args:
823 ; RV64I-LARGE: # %bb.0:
824 ; RV64I-LARGE-NEXT: addi sp, sp, -32
825 ; RV64I-LARGE-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
826 ; RV64I-LARGE-NEXT: .Lpcrel_hi5:
827 ; RV64I-LARGE-NEXT: auipc a1, %pcrel_hi(.LCPI10_0)
828 ; RV64I-LARGE-NEXT: ld t1, %pcrel_lo(.Lpcrel_hi5)(a1)
829 ; RV64I-LARGE-NEXT: sd a0, 0(sp)
830 ; RV64I-LARGE-NEXT: sd a0, 8(sp)
831 ; RV64I-LARGE-NEXT: mv a1, a0
832 ; RV64I-LARGE-NEXT: mv a2, a0
833 ; RV64I-LARGE-NEXT: mv a3, a0
834 ; RV64I-LARGE-NEXT: mv a4, a0
835 ; RV64I-LARGE-NEXT: mv a5, a0
836 ; RV64I-LARGE-NEXT: mv a6, a0
837 ; RV64I-LARGE-NEXT: mv a7, a0
838 ; RV64I-LARGE-NEXT: jalr t1
839 ; RV64I-LARGE-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
840 ; RV64I-LARGE-NEXT: addi sp, sp, 32
841 ; RV64I-LARGE-NEXT: ret
843 ; RV64I-LARGE-ZICFILP-LABEL: test_call_defined_many_args:
844 ; RV64I-LARGE-ZICFILP: # %bb.0:
845 ; RV64I-LARGE-ZICFILP-NEXT: lpad 0
846 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, -32
847 ; RV64I-LARGE-ZICFILP-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
848 ; RV64I-LARGE-ZICFILP-NEXT: .Lpcrel_hi5:
849 ; RV64I-LARGE-ZICFILP-NEXT: auipc a1, %pcrel_hi(.LCPI10_0)
850 ; RV64I-LARGE-ZICFILP-NEXT: ld t2, %pcrel_lo(.Lpcrel_hi5)(a1)
851 ; RV64I-LARGE-ZICFILP-NEXT: sd a0, 0(sp)
852 ; RV64I-LARGE-ZICFILP-NEXT: sd a0, 8(sp)
853 ; RV64I-LARGE-ZICFILP-NEXT: mv a1, a0
854 ; RV64I-LARGE-ZICFILP-NEXT: mv a2, a0
855 ; RV64I-LARGE-ZICFILP-NEXT: mv a3, a0
856 ; RV64I-LARGE-ZICFILP-NEXT: mv a4, a0
857 ; RV64I-LARGE-ZICFILP-NEXT: mv a5, a0
858 ; RV64I-LARGE-ZICFILP-NEXT: mv a6, a0
859 ; RV64I-LARGE-ZICFILP-NEXT: mv a7, a0
860 ; RV64I-LARGE-ZICFILP-NEXT: jalr t2
861 ; RV64I-LARGE-ZICFILP-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
862 ; RV64I-LARGE-ZICFILP-NEXT: addi sp, sp, 32
863 ; RV64I-LARGE-ZICFILP-NEXT: ret
864 %1 = call i32 @defined_many_args(i32 %a, i32 %a, i32 %a, i32 %a, i32 %a,
865 i32 %a, i32 %a, i32 %a, i32 %a, i32 %a)
868 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: