1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
3 ;; Test how memcpy is optimized when ual is turned off which is similar to AArch64/arm64-misaligned-memcpy-inline.ll.
5 ; RUN: llc --mtriple=loongarch32 --mattr=-ual < %s | FileCheck %s --check-prefix=LA32
6 ; RUN: llc --mtriple=loongarch64 --mattr=-ual < %s | FileCheck %s --check-prefix=LA64
8 ;; Small (16 bytes here) unaligned memcpy() should be a function call if
10 define void @t0(ptr %out, ptr %in) {
12 ; LA32: # %bb.0: # %entry
13 ; LA32-NEXT: addi.w $sp, $sp, -16
14 ; LA32-NEXT: .cfi_def_cfa_offset 16
15 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
16 ; LA32-NEXT: .cfi_offset 1, -4
17 ; LA32-NEXT: ori $a2, $zero, 16
18 ; LA32-NEXT: bl %plt(memcpy)
19 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
20 ; LA32-NEXT: addi.w $sp, $sp, 16
24 ; LA64: # %bb.0: # %entry
25 ; LA64-NEXT: addi.d $sp, $sp, -16
26 ; LA64-NEXT: .cfi_def_cfa_offset 16
27 ; LA64-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
28 ; LA64-NEXT: .cfi_offset 1, -8
29 ; LA64-NEXT: ori $a2, $zero, 16
30 ; LA64-NEXT: bl %plt(memcpy)
31 ; LA64-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
32 ; LA64-NEXT: addi.d $sp, $sp, 16
35 call void @llvm.memcpy.p0.p0.i64(ptr %out, ptr %in, i64 16, i1 false)
39 ;; Small (16 bytes here) aligned memcpy() should be inlined even if
41 define void @t1(ptr align 8 %out, ptr align 8 %in) {
43 ; LA32: # %bb.0: # %entry
44 ; LA32-NEXT: ld.w $a2, $a1, 12
45 ; LA32-NEXT: st.w $a2, $a0, 12
46 ; LA32-NEXT: ld.w $a2, $a1, 8
47 ; LA32-NEXT: st.w $a2, $a0, 8
48 ; LA32-NEXT: ld.w $a2, $a1, 4
49 ; LA32-NEXT: st.w $a2, $a0, 4
50 ; LA32-NEXT: ld.w $a1, $a1, 0
51 ; LA32-NEXT: st.w $a1, $a0, 0
55 ; LA64: # %bb.0: # %entry
56 ; LA64-NEXT: ld.d $a2, $a1, 8
57 ; LA64-NEXT: st.d $a2, $a0, 8
58 ; LA64-NEXT: ld.d $a1, $a1, 0
59 ; LA64-NEXT: st.d $a1, $a0, 0
62 call void @llvm.memcpy.p0.p0.i64(ptr align 8 %out, ptr align 8 %in, i64 16, i1 false)
66 ;; Tiny (4 bytes here) unaligned memcpy() should be inlined with byte sized
67 ;; loads and stores if ual is turned off.
68 define void @t2(ptr %out, ptr %in) {
70 ; LA32: # %bb.0: # %entry
71 ; LA32-NEXT: ld.b $a2, $a1, 3
72 ; LA32-NEXT: st.b $a2, $a0, 3
73 ; LA32-NEXT: ld.b $a2, $a1, 2
74 ; LA32-NEXT: st.b $a2, $a0, 2
75 ; LA32-NEXT: ld.b $a2, $a1, 1
76 ; LA32-NEXT: st.b $a2, $a0, 1
77 ; LA32-NEXT: ld.b $a1, $a1, 0
78 ; LA32-NEXT: st.b $a1, $a0, 0
82 ; LA64: # %bb.0: # %entry
83 ; LA64-NEXT: ld.b $a2, $a1, 3
84 ; LA64-NEXT: st.b $a2, $a0, 3
85 ; LA64-NEXT: ld.b $a2, $a1, 2
86 ; LA64-NEXT: st.b $a2, $a0, 2
87 ; LA64-NEXT: ld.b $a2, $a1, 1
88 ; LA64-NEXT: st.b $a2, $a0, 1
89 ; LA64-NEXT: ld.b $a1, $a1, 0
90 ; LA64-NEXT: st.b $a1, $a0, 0
93 call void @llvm.memcpy.p0.p0.i64(ptr %out, ptr %in, i64 4, i1 false)
97 declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture readonly, i64, i1)