1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=riscv32 \
3 ; RUN: | FileCheck %s --check-prefixes=RV32-BOTH,RV32
4 ; RUN: llc < %s -mtriple=riscv64 \
5 ; RUN: | FileCheck %s --check-prefixes=RV64-BOTH,RV64
6 ; RUN: llc < %s -mtriple=riscv32 -mattr=+fast-unaligned-access \
7 ; RUN: | FileCheck %s --check-prefixes=RV32-BOTH,RV32-FAST
8 ; RUN: llc < %s -mtriple=riscv64 -mattr=+fast-unaligned-access \
9 ; RUN: | FileCheck %s --check-prefixes=RV64-BOTH,RV64-FAST
10 %struct.x = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }
12 @src = external dso_local global %struct.x
13 @dst = external dso_local global %struct.x
15 @.str1 = private unnamed_addr constant [31 x i8] c"DHRYSTONE PROGRAM, SOME STRING\00", align 1
16 @.str2 = private unnamed_addr constant [36 x i8] c"DHRYSTONE PROGRAM, SOME STRING BLAH\00", align 1
17 @.str3 = private unnamed_addr constant [24 x i8] c"DHRYSTONE PROGRAM, SOME\00", align 1
18 @.str4 = private unnamed_addr constant [18 x i8] c"DHRYSTONE PROGR \00", align 1
19 @.str5 = private unnamed_addr constant [7 x i8] c"DHRYST\00", align 1
20 @.str6 = private unnamed_addr constant [14 x i8] c"/tmp/rmXXXXXX\00", align 1
21 @spool.splbuf = internal global [512 x i8] zeroinitializer, align 16
25 ; RV32: # %bb.0: # %entry
26 ; RV32-NEXT: lui a0, %hi(src)
27 ; RV32-NEXT: lw a1, %lo(src)(a0)
28 ; RV32-NEXT: lui a2, %hi(dst)
29 ; RV32-NEXT: sw a1, %lo(dst)(a2)
30 ; RV32-NEXT: addi a0, a0, %lo(src)
31 ; RV32-NEXT: lbu a1, 10(a0)
32 ; RV32-NEXT: lh a3, 8(a0)
33 ; RV32-NEXT: lw a0, 4(a0)
34 ; RV32-NEXT: addi a2, a2, %lo(dst)
35 ; RV32-NEXT: sb a1, 10(a2)
36 ; RV32-NEXT: sh a3, 8(a2)
37 ; RV32-NEXT: sw a0, 4(a2)
42 ; RV64: # %bb.0: # %entry
43 ; RV64-NEXT: lui a0, %hi(src)
44 ; RV64-NEXT: ld a1, %lo(src)(a0)
45 ; RV64-NEXT: lui a2, %hi(dst)
46 ; RV64-NEXT: addi a0, a0, %lo(src)
47 ; RV64-NEXT: lbu a3, 10(a0)
48 ; RV64-NEXT: lh a0, 8(a0)
49 ; RV64-NEXT: sd a1, %lo(dst)(a2)
50 ; RV64-NEXT: addi a1, a2, %lo(dst)
51 ; RV64-NEXT: sb a3, 10(a1)
52 ; RV64-NEXT: sh a0, 8(a1)
56 ; RV32-FAST-LABEL: t0:
57 ; RV32-FAST: # %bb.0: # %entry
58 ; RV32-FAST-NEXT: lui a0, %hi(src)
59 ; RV32-FAST-NEXT: lw a1, %lo(src)(a0)
60 ; RV32-FAST-NEXT: lui a2, %hi(dst)
61 ; RV32-FAST-NEXT: addi a0, a0, %lo(src)
62 ; RV32-FAST-NEXT: lw a3, 7(a0)
63 ; RV32-FAST-NEXT: lw a0, 4(a0)
64 ; RV32-FAST-NEXT: sw a1, %lo(dst)(a2)
65 ; RV32-FAST-NEXT: addi a1, a2, %lo(dst)
66 ; RV32-FAST-NEXT: sw a3, 7(a1)
67 ; RV32-FAST-NEXT: sw a0, 4(a1)
68 ; RV32-FAST-NEXT: li a0, 0
71 ; RV64-FAST-LABEL: t0:
72 ; RV64-FAST: # %bb.0: # %entry
73 ; RV64-FAST-NEXT: lui a0, %hi(src)
74 ; RV64-FAST-NEXT: ld a1, %lo(src)(a0)
75 ; RV64-FAST-NEXT: addi a0, a0, %lo(src)
76 ; RV64-FAST-NEXT: lw a0, 7(a0)
77 ; RV64-FAST-NEXT: lui a2, %hi(dst)
78 ; RV64-FAST-NEXT: sd a1, %lo(dst)(a2)
79 ; RV64-FAST-NEXT: addi a1, a2, %lo(dst)
80 ; RV64-FAST-NEXT: sw a0, 7(a1)
81 ; RV64-FAST-NEXT: li a0, 0
84 call void @llvm.memcpy.p0.p0.i32(ptr align 8 @dst, ptr align 8 @src, i32 11, i1 false)
88 define void @t1(ptr nocapture %C) nounwind {
90 ; RV32: # %bb.0: # %entry
91 ; RV32-NEXT: lui a1, %hi(.L.str1)
92 ; RV32-NEXT: addi a1, a1, %lo(.L.str1)
93 ; RV32-NEXT: li a2, 31
94 ; RV32-NEXT: tail memcpy
97 ; RV64: # %bb.0: # %entry
98 ; RV64-NEXT: lui a1, %hi(.L.str1)
99 ; RV64-NEXT: addi a1, a1, %lo(.L.str1)
100 ; RV64-NEXT: li a2, 31
101 ; RV64-NEXT: tail memcpy
103 ; RV32-FAST-LABEL: t1:
104 ; RV32-FAST: # %bb.0: # %entry
105 ; RV32-FAST-NEXT: lui a1, 1141
106 ; RV32-FAST-NEXT: addi a1, a1, -439
107 ; RV32-FAST-NEXT: sw a1, 27(a0)
108 ; RV32-FAST-NEXT: lui a1, 300325
109 ; RV32-FAST-NEXT: addi a1, a1, 1107
110 ; RV32-FAST-NEXT: sw a1, 24(a0)
111 ; RV32-FAST-NEXT: lui a1, 132181
112 ; RV32-FAST-NEXT: addi a1, a1, -689
113 ; RV32-FAST-NEXT: sw a1, 20(a0)
114 ; RV32-FAST-NEXT: lui a1, 340483
115 ; RV32-FAST-NEXT: addi a1, a1, -947
116 ; RV32-FAST-NEXT: sw a1, 16(a0)
117 ; RV32-FAST-NEXT: lui a1, 267556
118 ; RV32-FAST-NEXT: addi a1, a1, 1871
119 ; RV32-FAST-NEXT: sw a1, 12(a0)
120 ; RV32-FAST-NEXT: lui a1, 337154
121 ; RV32-FAST-NEXT: addi a1, a1, 69
122 ; RV32-FAST-NEXT: sw a1, 8(a0)
123 ; RV32-FAST-NEXT: lui a1, 320757
124 ; RV32-FAST-NEXT: addi a1, a1, 1107
125 ; RV32-FAST-NEXT: sw a1, 4(a0)
126 ; RV32-FAST-NEXT: lui a1, 365861
127 ; RV32-FAST-NEXT: addi a1, a1, -1980
128 ; RV32-FAST-NEXT: sw a1, 0(a0)
129 ; RV32-FAST-NEXT: ret
131 ; RV64-FAST-LABEL: t1:
132 ; RV64-FAST: # %bb.0: # %entry
133 ; RV64-FAST-NEXT: lui a1, %hi(.L.str1)
134 ; RV64-FAST-NEXT: ld a2, %lo(.L.str1)(a1)
135 ; RV64-FAST-NEXT: addi a1, a1, %lo(.L.str1)
136 ; RV64-FAST-NEXT: ld a3, 23(a1)
137 ; RV64-FAST-NEXT: ld a4, 16(a1)
138 ; RV64-FAST-NEXT: ld a1, 8(a1)
139 ; RV64-FAST-NEXT: sd a2, 0(a0)
140 ; RV64-FAST-NEXT: sd a3, 23(a0)
141 ; RV64-FAST-NEXT: sd a4, 16(a0)
142 ; RV64-FAST-NEXT: sd a1, 8(a0)
143 ; RV64-FAST-NEXT: ret
145 tail call void @llvm.memcpy.p0.p0.i64(ptr %C, ptr @.str1, i64 31, i1 false)
149 define void @t2(ptr nocapture %C) nounwind {
150 ; RV32-BOTH-LABEL: t2:
151 ; RV32-BOTH: # %bb.0: # %entry
152 ; RV32-BOTH-NEXT: lui a1, %hi(.L.str2)
153 ; RV32-BOTH-NEXT: addi a1, a1, %lo(.L.str2)
154 ; RV32-BOTH-NEXT: li a2, 36
155 ; RV32-BOTH-NEXT: tail memcpy
158 ; RV64: # %bb.0: # %entry
159 ; RV64-NEXT: lui a1, %hi(.L.str2)
160 ; RV64-NEXT: addi a1, a1, %lo(.L.str2)
161 ; RV64-NEXT: li a2, 36
162 ; RV64-NEXT: tail memcpy
164 ; RV64-FAST-LABEL: t2:
165 ; RV64-FAST: # %bb.0: # %entry
166 ; RV64-FAST-NEXT: lui a1, %hi(.L.str2)
167 ; RV64-FAST-NEXT: ld a2, %lo(.L.str2)(a1)
168 ; RV64-FAST-NEXT: sd a2, 0(a0)
169 ; RV64-FAST-NEXT: lui a2, 1156
170 ; RV64-FAST-NEXT: addi a2, a2, 332
171 ; RV64-FAST-NEXT: addi a1, a1, %lo(.L.str2)
172 ; RV64-FAST-NEXT: ld a3, 24(a1)
173 ; RV64-FAST-NEXT: ld a4, 16(a1)
174 ; RV64-FAST-NEXT: ld a1, 8(a1)
175 ; RV64-FAST-NEXT: sw a2, 32(a0)
176 ; RV64-FAST-NEXT: sd a3, 24(a0)
177 ; RV64-FAST-NEXT: sd a4, 16(a0)
178 ; RV64-FAST-NEXT: sd a1, 8(a0)
179 ; RV64-FAST-NEXT: ret
181 tail call void @llvm.memcpy.p0.p0.i64(ptr %C, ptr @.str2, i64 36, i1 false)
185 define void @t3(ptr nocapture %C) nounwind {
187 ; RV32: # %bb.0: # %entry
188 ; RV32-NEXT: lui a1, %hi(.L.str3)
189 ; RV32-NEXT: addi a1, a1, %lo(.L.str3)
190 ; RV32-NEXT: li a2, 24
191 ; RV32-NEXT: tail memcpy
194 ; RV64: # %bb.0: # %entry
195 ; RV64-NEXT: lui a1, %hi(.L.str3)
196 ; RV64-NEXT: addi a1, a1, %lo(.L.str3)
197 ; RV64-NEXT: li a2, 24
198 ; RV64-NEXT: tail memcpy
200 ; RV32-FAST-LABEL: t3:
201 ; RV32-FAST: # %bb.0: # %entry
202 ; RV32-FAST-NEXT: lui a1, 1109
203 ; RV32-FAST-NEXT: addi a1, a1, -689
204 ; RV32-FAST-NEXT: sw a1, 20(a0)
205 ; RV32-FAST-NEXT: lui a1, 340483
206 ; RV32-FAST-NEXT: addi a1, a1, -947
207 ; RV32-FAST-NEXT: sw a1, 16(a0)
208 ; RV32-FAST-NEXT: lui a1, 267556
209 ; RV32-FAST-NEXT: addi a1, a1, 1871
210 ; RV32-FAST-NEXT: sw a1, 12(a0)
211 ; RV32-FAST-NEXT: lui a1, 337154
212 ; RV32-FAST-NEXT: addi a1, a1, 69
213 ; RV32-FAST-NEXT: sw a1, 8(a0)
214 ; RV32-FAST-NEXT: lui a1, 320757
215 ; RV32-FAST-NEXT: addi a1, a1, 1107
216 ; RV32-FAST-NEXT: sw a1, 4(a0)
217 ; RV32-FAST-NEXT: lui a1, 365861
218 ; RV32-FAST-NEXT: addi a1, a1, -1980
219 ; RV32-FAST-NEXT: sw a1, 0(a0)
220 ; RV32-FAST-NEXT: ret
222 ; RV64-FAST-LABEL: t3:
223 ; RV64-FAST: # %bb.0: # %entry
224 ; RV64-FAST-NEXT: lui a1, %hi(.L.str3)
225 ; RV64-FAST-NEXT: ld a2, %lo(.L.str3)(a1)
226 ; RV64-FAST-NEXT: addi a1, a1, %lo(.L.str3)
227 ; RV64-FAST-NEXT: ld a3, 16(a1)
228 ; RV64-FAST-NEXT: ld a1, 8(a1)
229 ; RV64-FAST-NEXT: sd a2, 0(a0)
230 ; RV64-FAST-NEXT: sd a3, 16(a0)
231 ; RV64-FAST-NEXT: sd a1, 8(a0)
232 ; RV64-FAST-NEXT: ret
234 tail call void @llvm.memcpy.p0.p0.i64(ptr %C, ptr @.str3, i64 24, i1 false)
238 define void @t4(ptr nocapture %C) nounwind {
240 ; RV32: # %bb.0: # %entry
241 ; RV32-NEXT: lui a1, %hi(.L.str4)
242 ; RV32-NEXT: addi a1, a1, %lo(.L.str4)
243 ; RV32-NEXT: li a2, 18
244 ; RV32-NEXT: tail memcpy
247 ; RV64: # %bb.0: # %entry
248 ; RV64-NEXT: lui a1, %hi(.L.str4)
249 ; RV64-NEXT: addi a1, a1, %lo(.L.str4)
250 ; RV64-NEXT: li a2, 18
251 ; RV64-NEXT: tail memcpy
253 ; RV32-FAST-LABEL: t4:
254 ; RV32-FAST: # %bb.0: # %entry
255 ; RV32-FAST-NEXT: li a1, 32
256 ; RV32-FAST-NEXT: sh a1, 16(a0)
257 ; RV32-FAST-NEXT: lui a1, 132388
258 ; RV32-FAST-NEXT: addi a1, a1, 1871
259 ; RV32-FAST-NEXT: sw a1, 12(a0)
260 ; RV32-FAST-NEXT: lui a1, 337154
261 ; RV32-FAST-NEXT: addi a1, a1, 69
262 ; RV32-FAST-NEXT: sw a1, 8(a0)
263 ; RV32-FAST-NEXT: lui a1, 320757
264 ; RV32-FAST-NEXT: addi a1, a1, 1107
265 ; RV32-FAST-NEXT: sw a1, 4(a0)
266 ; RV32-FAST-NEXT: lui a1, 365861
267 ; RV32-FAST-NEXT: addi a1, a1, -1980
268 ; RV32-FAST-NEXT: sw a1, 0(a0)
269 ; RV32-FAST-NEXT: ret
271 ; RV64-FAST-LABEL: t4:
272 ; RV64-FAST: # %bb.0: # %entry
273 ; RV64-FAST-NEXT: lui a1, %hi(.L.str4)
274 ; RV64-FAST-NEXT: ld a2, %lo(.L.str4)(a1)
275 ; RV64-FAST-NEXT: addi a1, a1, %lo(.L.str4)
276 ; RV64-FAST-NEXT: ld a1, 8(a1)
277 ; RV64-FAST-NEXT: li a3, 32
278 ; RV64-FAST-NEXT: sh a3, 16(a0)
279 ; RV64-FAST-NEXT: sd a2, 0(a0)
280 ; RV64-FAST-NEXT: sd a1, 8(a0)
281 ; RV64-FAST-NEXT: ret
283 tail call void @llvm.memcpy.p0.p0.i64(ptr %C, ptr @.str4, i64 18, i1 false)
287 define void @t5(ptr nocapture %C) nounwind {
289 ; RV32: # %bb.0: # %entry
290 ; RV32-NEXT: sb zero, 6(a0)
291 ; RV32-NEXT: li a1, 84
292 ; RV32-NEXT: sb a1, 5(a0)
293 ; RV32-NEXT: li a1, 83
294 ; RV32-NEXT: sb a1, 4(a0)
295 ; RV32-NEXT: li a1, 89
296 ; RV32-NEXT: sb a1, 3(a0)
297 ; RV32-NEXT: li a1, 82
298 ; RV32-NEXT: sb a1, 2(a0)
299 ; RV32-NEXT: li a1, 72
300 ; RV32-NEXT: sb a1, 1(a0)
301 ; RV32-NEXT: li a1, 68
302 ; RV32-NEXT: sb a1, 0(a0)
306 ; RV64: # %bb.0: # %entry
307 ; RV64-NEXT: sb zero, 6(a0)
308 ; RV64-NEXT: li a1, 84
309 ; RV64-NEXT: sb a1, 5(a0)
310 ; RV64-NEXT: li a1, 83
311 ; RV64-NEXT: sb a1, 4(a0)
312 ; RV64-NEXT: li a1, 89
313 ; RV64-NEXT: sb a1, 3(a0)
314 ; RV64-NEXT: li a1, 82
315 ; RV64-NEXT: sb a1, 2(a0)
316 ; RV64-NEXT: li a1, 72
317 ; RV64-NEXT: sb a1, 1(a0)
318 ; RV64-NEXT: li a1, 68
319 ; RV64-NEXT: sb a1, 0(a0)
322 ; RV32-FAST-LABEL: t5:
323 ; RV32-FAST: # %bb.0: # %entry
324 ; RV32-FAST-NEXT: lui a1, 1349
325 ; RV32-FAST-NEXT: addi a1, a1, 857
326 ; RV32-FAST-NEXT: sw a1, 3(a0)
327 ; RV32-FAST-NEXT: lui a1, 365861
328 ; RV32-FAST-NEXT: addi a1, a1, -1980
329 ; RV32-FAST-NEXT: sw a1, 0(a0)
330 ; RV32-FAST-NEXT: ret
332 ; RV64-FAST-LABEL: t5:
333 ; RV64-FAST: # %bb.0: # %entry
334 ; RV64-FAST-NEXT: lui a1, 1349
335 ; RV64-FAST-NEXT: addi a1, a1, 857
336 ; RV64-FAST-NEXT: sw a1, 3(a0)
337 ; RV64-FAST-NEXT: lui a1, 365861
338 ; RV64-FAST-NEXT: addi a1, a1, -1980
339 ; RV64-FAST-NEXT: sw a1, 0(a0)
340 ; RV64-FAST-NEXT: ret
342 tail call void @llvm.memcpy.p0.p0.i64(ptr %C, ptr @.str5, i64 7, i1 false)
346 define void @t6() nounwind {
348 ; RV32: # %bb.0: # %entry
349 ; RV32-NEXT: addi sp, sp, -16
350 ; RV32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
351 ; RV32-NEXT: lui a0, %hi(spool.splbuf)
352 ; RV32-NEXT: addi a0, a0, %lo(spool.splbuf)
353 ; RV32-NEXT: lui a1, %hi(.L.str6)
354 ; RV32-NEXT: addi a1, a1, %lo(.L.str6)
355 ; RV32-NEXT: li a2, 14
356 ; RV32-NEXT: call memcpy
357 ; RV32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
358 ; RV32-NEXT: addi sp, sp, 16
362 ; RV64: # %bb.0: # %entry
363 ; RV64-NEXT: addi sp, sp, -16
364 ; RV64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
365 ; RV64-NEXT: lui a0, %hi(spool.splbuf)
366 ; RV64-NEXT: addi a0, a0, %lo(spool.splbuf)
367 ; RV64-NEXT: lui a1, %hi(.L.str6)
368 ; RV64-NEXT: addi a1, a1, %lo(.L.str6)
369 ; RV64-NEXT: li a2, 14
370 ; RV64-NEXT: call memcpy
371 ; RV64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
372 ; RV64-NEXT: addi sp, sp, 16
375 ; RV32-FAST-LABEL: t6:
376 ; RV32-FAST: # %bb.0: # %entry
377 ; RV32-FAST-NEXT: lui a0, %hi(spool.splbuf)
378 ; RV32-FAST-NEXT: li a1, 88
379 ; RV32-FAST-NEXT: sh a1, %lo(spool.splbuf+12)(a0)
380 ; RV32-FAST-NEXT: lui a1, 361862
381 ; RV32-FAST-NEXT: addi a1, a1, -1960
382 ; RV32-FAST-NEXT: sw a1, %lo(spool.splbuf+8)(a0)
383 ; RV32-FAST-NEXT: lui a1, 362199
384 ; RV32-FAST-NEXT: addi a1, a1, 559
385 ; RV32-FAST-NEXT: sw a1, %lo(spool.splbuf+4)(a0)
386 ; RV32-FAST-NEXT: lui a1, 460503
387 ; RV32-FAST-NEXT: addi a1, a1, 1071
388 ; RV32-FAST-NEXT: sw a1, %lo(spool.splbuf)(a0)
389 ; RV32-FAST-NEXT: ret
391 ; RV64-FAST-LABEL: t6:
392 ; RV64-FAST: # %bb.0: # %entry
393 ; RV64-FAST-NEXT: lui a0, %hi(.L.str6)
394 ; RV64-FAST-NEXT: ld a1, %lo(.L.str6)(a0)
395 ; RV64-FAST-NEXT: addi a0, a0, %lo(.L.str6)
396 ; RV64-FAST-NEXT: ld a0, 6(a0)
397 ; RV64-FAST-NEXT: lui a2, %hi(spool.splbuf)
398 ; RV64-FAST-NEXT: sd a1, %lo(spool.splbuf)(a2)
399 ; RV64-FAST-NEXT: sd a0, %lo(spool.splbuf+6)(a2)
400 ; RV64-FAST-NEXT: ret
402 call void @llvm.memcpy.p0.p0.i64(ptr @spool.splbuf, ptr @.str6, i64 14, i1 false)
406 %struct.Foo = type { i32, i32, i32, i32 }
408 define void @t7(ptr nocapture %a, ptr nocapture %b) nounwind {
409 ; RV32-BOTH-LABEL: t7:
410 ; RV32-BOTH: # %bb.0: # %entry
411 ; RV32-BOTH-NEXT: lw a2, 12(a1)
412 ; RV32-BOTH-NEXT: sw a2, 12(a0)
413 ; RV32-BOTH-NEXT: lw a2, 8(a1)
414 ; RV32-BOTH-NEXT: sw a2, 8(a0)
415 ; RV32-BOTH-NEXT: lw a2, 4(a1)
416 ; RV32-BOTH-NEXT: sw a2, 4(a0)
417 ; RV32-BOTH-NEXT: lw a1, 0(a1)
418 ; RV32-BOTH-NEXT: sw a1, 0(a0)
419 ; RV32-BOTH-NEXT: ret
422 ; RV64: # %bb.0: # %entry
423 ; RV64-NEXT: lw a2, 12(a1)
424 ; RV64-NEXT: sw a2, 12(a0)
425 ; RV64-NEXT: lw a2, 8(a1)
426 ; RV64-NEXT: sw a2, 8(a0)
427 ; RV64-NEXT: lw a2, 4(a1)
428 ; RV64-NEXT: sw a2, 4(a0)
429 ; RV64-NEXT: lw a1, 0(a1)
430 ; RV64-NEXT: sw a1, 0(a0)
433 ; RV64-FAST-LABEL: t7:
434 ; RV64-FAST: # %bb.0: # %entry
435 ; RV64-FAST-NEXT: ld a2, 8(a1)
436 ; RV64-FAST-NEXT: sd a2, 8(a0)
437 ; RV64-FAST-NEXT: ld a1, 0(a1)
438 ; RV64-FAST-NEXT: sd a1, 0(a0)
439 ; RV64-FAST-NEXT: ret
441 tail call void @llvm.memcpy.p0.p0.i32(ptr align 4 %a, ptr align 4 %b, i32 16, i1 false)
445 declare void @llvm.memcpy.p0.p0.i32(ptr nocapture, ptr nocapture, i32, i1) nounwind
446 declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1) nounwind
447 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: