1; RUN: llc < %s -mtriple=arm64-eabi -mcpu=cyclone | FileCheck %s
2
3%struct.x = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }
4
5@src = external global %struct.x
6@dst = external global %struct.x
7
8@.str1 = private unnamed_addr constant [31 x i8] c"DHRYSTONE PROGRAM, SOME STRING\00", align 1
9@.str2 = private unnamed_addr constant [36 x i8] c"DHRYSTONE PROGRAM, SOME STRING BLAH\00", align 1
10@.str3 = private unnamed_addr constant [24 x i8] c"DHRYSTONE PROGRAM, SOME\00", align 1
11@.str4 = private unnamed_addr constant [18 x i8] c"DHRYSTONE PROGR  \00", align 1
12@.str5 = private unnamed_addr constant [7 x i8] c"DHRYST\00", align 1
13@.str6 = private unnamed_addr constant [14 x i8] c"/tmp/rmXXXXXX\00", align 1
14@spool.splbuf = internal global [512 x i8] zeroinitializer, align 16
15
16define i32 @t0() {
17entry:
18; CHECK-LABEL: t0:
19; CHECK-DAG: ldur [[REG0:w[0-9]+]], [x[[BASEREG:[0-9]+]], #7]
20; CHECK-DAG: stur [[REG0]], [x[[BASEREG2:[0-9]+]], #7]
21; CHECK-DAG: ldr [[REG2:x[0-9]+]],
22; CHECK-DAG: str [[REG2]],
23  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 getelementptr inbounds (%struct.x, %struct.x* @dst, i32 0, i32 0), i8* align 8 getelementptr inbounds (%struct.x, %struct.x* @src, i32 0, i32 0), i32 11, i1 false)
24  ret i32 0
25}
26
27define void @t1(i8* nocapture %C) nounwind {
28entry:
29; CHECK-LABEL: t1:
30; CHECK: ldr [[DEST:q[0-9]+]], [x[[BASEREG]]]
31; CHECK: ldur [[DEST:q[0-9]+]], [x[[BASEREG:[0-9]+]], #15]
32; CHECK: stur [[DEST:q[0-9]+]], [x0, #15]
33; CHECK: str [[DEST:q[0-9]+]], [x0]
34  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %C, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str1, i64 0, i64 0), i64 31, i1 false)
35  ret void
36}
37
38define void @t2(i8* nocapture %C) nounwind {
39entry:
40; CHECK-LABEL: t2:
41; CHECK: mov [[REG3:w[0-9]+]]
42; CHECK: movk [[REG3]],
43; CHECK: str [[REG3]], [x0, #32]
44; CHECK: ldp [[DEST1:q[0-9]+]], [[DEST2:q[0-9]+]], [x{{[0-9]+}}]
45; CHECK: stp [[DEST1]], [[DEST2]], [x0]
46  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %C, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str2, i64 0, i64 0), i64 36, i1 false)
47  ret void
48}
49
50define void @t3(i8* nocapture %C) nounwind {
51entry:
52; CHECK-LABEL: t3:
53; CHECK: ldr [[DEST:q[0-9]+]], [x[[BASEREG]]]
54; CHECK: ldr [[REG4:x[0-9]+]], [x[[BASEREG:[0-9]+]], #16]
55; CHECK: str [[REG4]], [x0, #16]
56; CHECK: str [[DEST]], [x0]
57  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %C, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str3, i64 0, i64 0), i64 24, i1 false)
58  ret void
59}
60
61define void @t4(i8* nocapture %C) nounwind {
62entry:
63; CHECK-LABEL: t4:
64; CHECK: mov [[REG5:w[0-9]+]], #32
65; CHECK: strh [[REG5]], [x0, #16]
66; CHECK: ldr [[REG6:q[0-9]+]], [x{{[0-9]+}}]
67; CHECK: str [[REG6]], [x0]
68  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %C, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str4, i64 0, i64 0), i64 18, i1 false)
69  ret void
70}
71
72define void @t5(i8* nocapture %C) nounwind {
73entry:
74; CHECK-LABEL: t5:
75; CHECK: mov [[REG7:w[0-9]+]], #21337
76; CHECK: movk [[REG7]],
77; CHECK: stur [[REG7]], [x0, #3]
78; CHECK: mov [[REG8:w[0-9]+]],
79; CHECK: movk [[REG8]],
80; CHECK: str [[REG8]], [x0]
81  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %C, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str5, i64 0, i64 0), i64 7, i1 false)
82  ret void
83}
84
85define void @t6() nounwind {
86entry:
87; CHECK-LABEL: t6:
88; CHECK-DAG: ldur [[REG9:x[0-9]+]], [x{{[0-9]+}}, #6]
89; CHECK-DAG: stur [[REG9]], [x{{[0-9]+}}, #6]
90; CHECK-DAG: ldr
91; CHECK-DAG: str
92  call void @llvm.memcpy.p0i8.p0i8.i64(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @spool.splbuf, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str6, i64 0, i64 0), i64 14, i1 false)
93  ret void
94}
95
96%struct.Foo = type { i32, i32, i32, i32 }
97
98define void @t7(%struct.Foo* nocapture %a, %struct.Foo* nocapture %b) nounwind {
99entry:
100; CHECK: t7
101; CHECK: ldr [[REG10:q[0-9]+]], [x1]
102; CHECK: str [[REG10]], [x0]
103  %0 = bitcast %struct.Foo* %a to i8*
104  %1 = bitcast %struct.Foo* %b to i8*
105  tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 %1, i32 16, i1 false)
106  ret void
107}
108
109declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i1) nounwind
110declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i1) nounwind
111