1 ; RUN: llc -fast-isel-sink-local-values -O0 -fast-isel -fast-isel-abort=1 -verify-machineinstrs -relocation-model=dynamic-no-pic -mtriple=arm64-apple-ios < %s | FileCheck %s --check-prefix=ARM64
3 @message = global [80 x i8] c"The LLVM Compiler Infrastructure\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", align 16
4 @temp = common global [80 x i8] zeroinitializer, align 16
8 ; ARM64: adrp x8, _message@PAGE
9 ; ARM64: add x0, x8, _message@PAGEOFF
10 ; ARM64: mov [[REG:w[0-9]+]], wzr
11 ; ARM64: uxtb w1, [[REG]]
14 call void @llvm.memset.p0i8.i64(i8* align 16 getelementptr inbounds ([80 x i8], [80 x i8]* @message, i32 0, i32 0), i8 0, i64 80, i1 false)
18 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1)
22 ; ARM64: adrp x8, _temp@GOTPAGE
23 ; ARM64: ldr x0, [x8, _temp@GOTPAGEOFF]
24 ; ARM64: adrp x8, _message@PAGE
25 ; ARM64: add x1, x8, _message@PAGEOFF
28 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 getelementptr inbounds ([80 x i8], [80 x i8]* @temp, i32 0, i32 0), i8* align 16 getelementptr inbounds ([80 x i8], [80 x i8]* @message, i32 0, i32 0), i64 80, i1 false)
32 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i1)
36 ; ARM64: adrp x8, _temp@GOTPAGE
37 ; ARM64: ldr x0, [x8, _temp@GOTPAGEOFF]
38 ; ARM64: adrp x8, _message@PAGE
39 ; ARM64: add x1, x8, _message@PAGEOFF
42 call void @llvm.memmove.p0i8.p0i8.i64(i8* align 16 getelementptr inbounds ([80 x i8], [80 x i8]* @temp, i32 0, i32 0), i8* align 16 getelementptr inbounds ([80 x i8], [80 x i8]* @message, i32 0, i32 0), i64 20, i1 false)
46 declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i1)
50 ; ARM64: adrp x8, _temp@GOTPAGE
51 ; ARM64: ldr [[REG0:x[0-9]+]], [x8, _temp@GOTPAGEOFF]
52 ; ARM64: adrp [[REG1:x[0-9]+]], _message@PAGE
53 ; ARM64: add [[REG2:x[0-9]+]], [[REG1]], _message@PAGEOFF
54 ; ARM64: ldr x10, {{\[}}[[REG2]]{{\]}}
55 ; ARM64: str x10, {{\[}}[[REG0]]{{\]}}
56 ; ARM64: ldr x10, {{\[}}[[REG2]], #8]
57 ; ARM64: str x10, {{\[}}[[REG0]], #8]
58 ; ARM64: ldrb [[REG3:w[0-9]+]], {{\[}}[[REG2]], #16]
59 ; ARM64: strb [[REG3]], {{\[}}[[REG0]], #16]
61 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 getelementptr inbounds ([80 x i8], [80 x i8]* @temp, i32 0, i32 0), i8* align 16 getelementptr inbounds ([80 x i8], [80 x i8]* @message, i32 0, i32 0), i64 17, i1 false)
67 ; ARM64: adrp x8, _temp@GOTPAGE
68 ; ARM64: ldr [[REG0:x[0-9]+]], [x8, _temp@GOTPAGEOFF]
69 ; ARM64: adrp [[REG3:x[0-9]+]], _message@PAGE
70 ; ARM64: add [[REG1:x[0-9]+]], [[REG3]], _message@PAGEOFF
71 ; ARM64: ldr x10, {{\[}}[[REG1]]]
72 ; ARM64: str x10, {{\[}}[[REG0]]]
73 ; ARM64: ldr x10, {{\[}}[[REG1]], #8]
74 ; ARM64: str x10, {{\[}}[[REG0]], #8]
75 ; ARM64: ldrb [[REG4:w[0-9]+]], {{\[}}[[REG1]], #16]
76 ; ARM64: strb [[REG4]], {{\[}}[[REG0]], #16]
78 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 getelementptr inbounds ([80 x i8], [80 x i8]* @temp, i32 0, i32 0), i8* align 8 getelementptr inbounds ([80 x i8], [80 x i8]* @message, i32 0, i32 0), i64 17, i1 false)
84 ; ARM64: adrp x8, _temp@GOTPAGE
85 ; ARM64: ldr [[REG0:x[0-9]+]], [x8, _temp@GOTPAGEOFF]
86 ; ARM64: adrp [[REG1:x[0-9]+]], _message@PAGE
87 ; ARM64: add [[REG2:x[0-9]+]], [[REG1]], _message@PAGEOFF
88 ; ARM64: ldr w10, {{\[}}[[REG2]]]
89 ; ARM64: str w10, {{\[}}[[REG0]]]
90 ; ARM64: ldr w10, {{\[}}[[REG2]], #4]
91 ; ARM64: str w10, {{\[}}[[REG0]], #4]
92 ; ARM64: ldrb [[REG3:w[0-9]+]], {{\[}}[[REG2]], #8]
93 ; ARM64: strb [[REG3]], {{\[}}[[REG0]], #8]
95 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 getelementptr inbounds ([80 x i8], [80 x i8]* @temp, i32 0, i32 0), i8* align 4 getelementptr inbounds ([80 x i8], [80 x i8]* @message, i32 0, i32 0), i64 9, i1 false)
101 ; ARM64: adrp x8, _temp@GOTPAGE
102 ; ARM64: ldr [[REG0:x[0-9]+]], [x8, _temp@GOTPAGEOFF]
103 ; ARM64: adrp [[REG1:x[0-9]+]], _message@PAGE
104 ; ARM64: add [[REG2:x[0-9]+]], [[REG1]], _message@PAGEOFF
105 ; ARM64: ldrh w10, {{\[}}[[REG2]]]
106 ; ARM64: strh w10, {{\[}}[[REG0]]]
107 ; ARM64: ldrh w10, {{\[}}[[REG2]], #2]
108 ; ARM64: strh w10, {{\[}}[[REG0]], #2]
109 ; ARM64: ldrh w10, {{\[}}[[REG2]], #4]
110 ; ARM64: strh w10, {{\[}}[[REG0]], #4]
111 ; ARM64: ldrb [[REG3:w[0-9]+]], {{\[}}[[REG2]], #6]
112 ; ARM64: strb [[REG3]], {{\[}}[[REG0]], #6]
114 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 getelementptr inbounds ([80 x i8], [80 x i8]* @temp, i32 0, i32 0), i8* align 2 getelementptr inbounds ([80 x i8], [80 x i8]* @message, i32 0, i32 0), i64 7, i1 false)
120 ; ARM64: adrp x8, _temp@GOTPAGE
121 ; ARM64: ldr [[REG0:x[0-9]+]], [x8, _temp@GOTPAGEOFF]
122 ; ARM64: adrp [[REG1:x[0-9]+]], _message@PAGE
123 ; ARM64: add [[REG2:x[0-9]+]], [[REG1:x[0-9]+]], _message@PAGEOFF
124 ; ARM64: ldrb w10, {{\[}}[[REG2]]]
125 ; ARM64: strb w10, {{\[}}[[REG0]]]
126 ; ARM64: ldrb w10, {{\[}}[[REG2]], #1]
127 ; ARM64: strb w10, {{\[}}[[REG0]], #1]
128 ; ARM64: ldrb w10, {{\[}}[[REG2]], #2]
129 ; ARM64: strb w10, {{\[}}[[REG0]], #2]
130 ; ARM64: ldrb [[REG3:w[0-9]+]], {{\[}}[[REG2]], #3]
131 ; ARM64: strb [[REG3]], {{\[}}[[REG0]], #3]
133 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 getelementptr inbounds ([80 x i8], [80 x i8]* @temp, i32 0, i32 0), i8* align 1 getelementptr inbounds ([80 x i8], [80 x i8]* @message, i32 0, i32 0), i64 4, i1 false)
137 define void @test_distant_memcpy(i8* %dst) {
138 ; ARM64-LABEL: test_distant_memcpy:
139 ; ARM64: mov [[ARRAY:x[0-9]+]], sp
140 ; ARM64: mov [[OFFSET:x[0-9]+]], #8000
141 ; ARM64: add x[[ADDR:[0-9]+]], [[ARRAY]], [[OFFSET]]
142 ; ARM64: ldrb [[BYTE:w[0-9]+]], [x[[ADDR]]]
143 ; ARM64: strb [[BYTE]], [x0]
144 %array = alloca i8, i32 8192
145 %elem = getelementptr i8, i8* %array, i32 8000
146 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %elem, i64 1, i1 false)