1 ; RUN: llc < %s -march=bpfel -verify-machineinstrs -bpf-expand-memcpy-in-order | FileCheck %s
2 ; RUN: llc < %s -march=bpfeb -verify-machineinstrs -bpf-expand-memcpy-in-order | FileCheck %s
6 ; void cal_align1(ptr a, ptr b)
8 ; __builtin_memcpy(a, b, COPY_LEN);
11 ; void cal_align2(short *a, short *b)
13 ; __builtin_memcpy(a, b, COPY_LEN);
18 ; void cal_align4(int *a, int *b)
20 ; __builtin_memcpy(a, b, COPY_LEN);
25 ; void cal_align8(long long *a, long long *b)
27 ; __builtin_memcpy(a, b, COPY_LEN);
30 ; Function Attrs: nounwind
31 define dso_local void @cal_align1(ptr nocapture %a, ptr nocapture readonly %b) local_unnamed_addr #0 {
33 tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %a, ptr align 1 %b, i64 9, i1 false)
37 ; Function Attrs: argmemonly nounwind
38 declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1) #1
40 ; CHECK: [[SCRATCH_REG:r[0-9]]] = *(u8 *)([[SRC_REG:r[0-9]]] + 0)
41 ; CHECK: *(u8 *)([[DST_REG:r[0-9]]] + 0) = [[SCRATCH_REG]]
42 ; CHECK: [[SCRATCH_REG]] = *(u8 *)([[SRC_REG]] + 1)
43 ; CHECK: *(u8 *)([[DST_REG]] + 1) = [[SCRATCH_REG]]
44 ; CHECK: [[SCRATCH_REG]] = *(u8 *)([[SRC_REG]] + 2)
45 ; CHECK: *(u8 *)([[DST_REG]] + 2) = [[SCRATCH_REG]]
46 ; CHECK: [[SCRATCH_REG]] = *(u8 *)([[SRC_REG]] + 3)
47 ; CHECK: *(u8 *)([[DST_REG]] + 3) = [[SCRATCH_REG]]
48 ; CHECK: [[SCRATCH_REG]] = *(u8 *)([[SRC_REG]] + 4)
49 ; CHECK: *(u8 *)([[DST_REG]] + 4) = [[SCRATCH_REG]]
50 ; CHECK: [[SCRATCH_REG]] = *(u8 *)([[SRC_REG]] + 5)
51 ; CHECK: *(u8 *)([[DST_REG]] + 5) = [[SCRATCH_REG]]
52 ; CHECK: [[SCRATCH_REG]] = *(u8 *)([[SRC_REG]] + 6)
53 ; CHECK: *(u8 *)([[DST_REG]] + 6) = [[SCRATCH_REG]]
54 ; CHECK: [[SCRATCH_REG]] = *(u8 *)([[SRC_REG]] + 7)
55 ; CHECK: *(u8 *)([[DST_REG]] + 7) = [[SCRATCH_REG]]
56 ; CHECK: [[SCRATCH_REG]] = *(u8 *)([[SRC_REG]] + 8)
57 ; CHECK: *(u8 *)([[DST_REG]] + 8) = [[SCRATCH_REG]]
59 ; Function Attrs: nounwind
60 define dso_local void @cal_align2(ptr nocapture %a, ptr nocapture readonly %b) local_unnamed_addr #0 {
62 tail call void @llvm.memcpy.p0.p0.i64(ptr align 2 %a, ptr align 2 %b, i64 9, i1 false)
65 ; CHECK: [[SCRATCH_REG:r[0-9]]] = *(u16 *)([[SRC_REG:r[0-9]]] + 0)
66 ; CHECK: *(u16 *)([[DST_REG:r[0-9]]] + 0) = [[SCRATCH_REG]]
67 ; CHECK: [[SCRATCH_REG]] = *(u16 *)([[SRC_REG]] + 2)
68 ; CHECK: *(u16 *)([[DST_REG]] + 2) = [[SCRATCH_REG]]
69 ; CHECK: [[SCRATCH_REG]] = *(u16 *)([[SRC_REG]] + 4)
70 ; CHECK: *(u16 *)([[DST_REG]] + 4) = [[SCRATCH_REG]]
71 ; CHECK: [[SCRATCH_REG]] = *(u16 *)([[SRC_REG]] + 6)
72 ; CHECK: *(u16 *)([[DST_REG]] + 6) = [[SCRATCH_REG]]
73 ; CHECK: [[SCRATCH_REG]] = *(u8 *)([[SRC_REG]] + 8)
74 ; CHECK: *(u8 *)([[DST_REG]] + 8) = [[SCRATCH_REG]]
76 ; Function Attrs: nounwind
77 define dso_local void @cal_align4(ptr nocapture %a, ptr nocapture readonly %b) local_unnamed_addr #0 {
79 tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 %b, i64 19, i1 false)
82 ; CHECK: [[SCRATCH_REG:r[0-9]]] = *(u32 *)([[SRC_REG:r[0-9]]] + 0)
83 ; CHECK: *(u32 *)([[DST_REG:r[0-9]]] + 0) = [[SCRATCH_REG]]
84 ; CHECK: [[SCRATCH_REG]] = *(u32 *)([[SRC_REG]] + 4)
85 ; CHECK: *(u32 *)([[DST_REG]] + 4) = [[SCRATCH_REG]]
86 ; CHECK: [[SCRATCH_REG]] = *(u32 *)([[SRC_REG]] + 8)
87 ; CHECK: *(u32 *)([[DST_REG]] + 8) = [[SCRATCH_REG]]
88 ; CHECK: [[SCRATCH_REG]] = *(u32 *)([[SRC_REG]] + 12)
89 ; CHECK: *(u32 *)([[DST_REG]] + 12) = [[SCRATCH_REG]]
90 ; CHECK: [[SCRATCH_REG]] = *(u16 *)([[SRC_REG]] + 16)
91 ; CHECK: *(u16 *)([[DST_REG]] + 16) = [[SCRATCH_REG]]
92 ; CHECK: [[SCRATCH_REG]] = *(u8 *)([[SRC_REG]] + 18)
93 ; CHECK: *(u8 *)([[DST_REG]] + 18) = [[SCRATCH_REG]]
95 ; Function Attrs: nounwind
96 define dso_local void @cal_align8(ptr nocapture %a, ptr nocapture readonly %b) local_unnamed_addr #0 {
98 tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %a, ptr align 8 %b, i64 27, i1 false)
101 ; CHECK: [[SCRATCH_REG:r[0-9]]] = *(u64 *)([[SRC_REG:r[0-9]]] + 0)
102 ; CHECK: *(u64 *)([[DST_REG:r[0-9]]] + 0) = [[SCRATCH_REG]]
103 ; CHECK: [[SCRATCH_REG]] = *(u64 *)([[SRC_REG]] + 8)
104 ; CHECK: *(u64 *)([[DST_REG]] + 8) = [[SCRATCH_REG]]
105 ; CHECK: [[SCRATCH_REG]] = *(u64 *)([[SRC_REG]] + 16)
106 ; CHECK: *(u64 *)([[DST_REG]] + 16) = [[SCRATCH_REG]]
107 ; CHECK: [[SCRATCH_REG]] = *(u16 *)([[SRC_REG]] + 24)
108 ; CHECK: *(u16 *)([[DST_REG]] + 24) = [[SCRATCH_REG]]
109 ; CHECK: [[SCRATCH_REG]] = *(u8 *)([[SRC_REG]] + 26)
110 ; CHECK: *(u8 *)([[DST_REG]] + 26) = [[SCRATCH_REG]]