1 ; RUN: llc < %s -mtriple=arm64-eabi | FileCheck %s
3 define void @bzero_4_heap(i8* nocapture %c) {
4 ; CHECK-LABEL: bzero_4_heap:
7 call void @llvm.memset.p0i8.i64(i8* align 4 %c, i8 0, i64 4, i1 false)
11 define void @bzero_8_heap(i8* nocapture %c) {
12 ; CHECK-LABEL: bzero_8_heap:
13 ; CHECK: str xzr, [x0]
15 call void @llvm.memset.p0i8.i64(i8* align 8 %c, i8 0, i64 8, i1 false)
19 define void @bzero_12_heap(i8* nocapture %c) {
20 ; CHECK-LABEL: bzero_12_heap:
21 ; CHECK: str wzr, [x0, #8]
22 ; CHECK-NEXT: str xzr, [x0]
24 call void @llvm.memset.p0i8.i64(i8* align 8 %c, i8 0, i64 12, i1 false)
28 define void @bzero_16_heap(i8* nocapture %c) {
29 ; CHECK-LABEL: bzero_16_heap:
30 ; CHECK: stp xzr, xzr, [x0]
32 call void @llvm.memset.p0i8.i64(i8* align 8 %c, i8 0, i64 16, i1 false)
36 define void @bzero_32_heap(i8* nocapture %c) {
37 ; CHECK-LABEL: bzero_32_heap:
38 ; CHECK: movi v0.2d, #0000000000000000
39 ; CHECK-NEXT: stp q0, q0, [x0]
41 call void @llvm.memset.p0i8.i64(i8* align 8 %c, i8 0, i64 32, i1 false)
45 define void @bzero_64_heap(i8* nocapture %c) {
46 ; CHECK-LABEL: bzero_64_heap:
47 ; CHECK: movi v0.2d, #0000000000000000
48 ; CHECK-NEXT: stp q0, q0, [x0, #32]
49 ; CHECK-NEXT: stp q0, q0, [x0]
51 call void @llvm.memset.p0i8.i64(i8* align 8 %c, i8 0, i64 64, i1 false)
55 define void @bzero_4_stack() {
56 ; CHECK-LABEL: bzero_4_stack:
57 ; CHECK: str wzr, [sp, #12]
58 ; CHECK-NEXT: bl something
59 %buf = alloca [4 x i8], align 1
60 %cast = bitcast [4 x i8]* %buf to i8*
61 call void @llvm.memset.p0i8.i32(i8* %cast, i8 0, i32 4, i1 false)
62 call void @something(i8* %cast)
66 define void @bzero_8_stack() {
67 ; CHECK-LABEL: bzero_8_stack:
68 ; CHECK: str xzr, [sp, #8]
69 ; CHECK-NEXT: bl something
70 %buf = alloca [8 x i8], align 1
71 %cast = bitcast [8 x i8]* %buf to i8*
72 call void @llvm.memset.p0i8.i32(i8* %cast, i8 0, i32 8, i1 false)
73 call void @something(i8* %cast)
77 define void @bzero_12_stack() {
78 ; CHECK-LABEL: bzero_12_stack:
79 ; CHECK: str wzr, [sp, #8]
80 ; CHECK-NEXT: str xzr, [sp]
81 ; CHECK-NEXT: bl something
82 %buf = alloca [12 x i8], align 1
83 %cast = bitcast [12 x i8]* %buf to i8*
84 call void @llvm.memset.p0i8.i32(i8* %cast, i8 0, i32 12, i1 false)
85 call void @something(i8* %cast)
89 define void @bzero_16_stack() {
90 ; CHECK-LABEL: bzero_16_stack:
91 ; CHECK: stp xzr, x30, [sp, #8]
93 ; CHECK: str xzr, [sp]
94 ; CHECK-NEXT: bl something
95 %buf = alloca [16 x i8], align 1
96 %cast = bitcast [16 x i8]* %buf to i8*
97 call void @llvm.memset.p0i8.i32(i8* %cast, i8 0, i32 16, i1 false)
98 call void @something(i8* %cast)
102 define void @bzero_20_stack() {
103 ; CHECK-LABEL: bzero_20_stack:
104 ; CHECK: stp xzr, xzr, [sp, #8]
105 ; CHECK-NEXT: str wzr, [sp, #24]
106 ; CHECK-NEXT: bl something
107 %buf = alloca [20 x i8], align 1
108 %cast = bitcast [20 x i8]* %buf to i8*
109 call void @llvm.memset.p0i8.i32(i8* %cast, i8 0, i32 20, i1 false)
110 call void @something(i8* %cast)
114 define void @bzero_26_stack() {
115 ; CHECK-LABEL: bzero_26_stack:
116 ; CHECK: stp xzr, xzr, [sp, #8]
117 ; CHECK-NEXT: str xzr, [sp]
118 ; CHECK-NEXT: strh wzr, [sp, #24]
119 ; CHECK-NEXT: bl something
120 %buf = alloca [26 x i8], align 1
121 %cast = bitcast [26 x i8]* %buf to i8*
122 call void @llvm.memset.p0i8.i32(i8* %cast, i8 0, i32 26, i1 false)
123 call void @something(i8* %cast)
127 define void @bzero_32_stack() {
128 ; CHECK-LABEL: bzero_32_stack:
129 ; CHECK: movi v0.2d, #0000000000000000
130 ; CHECK-NEXT: mov x0, sp
131 ; CHECK-NEXT: stp q0, q0, [sp]
132 ; CHECK-NEXT: bl something
133 %buf = alloca [32 x i8], align 1
134 %cast = bitcast [32 x i8]* %buf to i8*
135 call void @llvm.memset.p0i8.i32(i8* %cast, i8 0, i32 32, i1 false)
136 call void @something(i8* %cast)
140 define void @bzero_40_stack() {
141 ; CHECK-LABEL: bzero_40_stack:
142 ; CHECK: movi v0.2d, #0000000000000000
143 ; CHECK-NEXT: mov x0, sp
144 ; CHECK-NEXT: str xzr, [sp, #32]
145 ; CHECK-NEXT: stp q0, q0, [sp]
146 ; CHECK-NEXT: bl something
147 %buf = alloca [40 x i8], align 1
148 %cast = bitcast [40 x i8]* %buf to i8*
149 call void @llvm.memset.p0i8.i32(i8* %cast, i8 0, i32 40, i1 false)
150 call void @something(i8* %cast)
154 define void @bzero_64_stack() {
155 ; CHECK-LABEL: bzero_64_stack:
156 ; CHECK: movi v0.2d, #0000000000000000
157 ; CHECK-NEXT: mov x0, sp
158 ; CHECK-NEXT: stp q0, q0, [sp, #32]
159 ; CHECK-NEXT: stp q0, q0, [sp]
160 ; CHECK-NEXT: bl something
161 %buf = alloca [64 x i8], align 1
162 %cast = bitcast [64 x i8]* %buf to i8*
163 call void @llvm.memset.p0i8.i32(i8* %cast, i8 0, i32 64, i1 false)
164 call void @something(i8* %cast)
168 define void @bzero_72_stack() {
169 ; CHECK-LABEL: bzero_72_stack:
170 ; CHECK: movi v0.2d, #0000000000000000
171 ; CHECK-NEXT: mov x0, sp
172 ; CHECK-NEXT: str xzr, [sp, #64]
173 ; CHECK-NEXT: stp q0, q0, [sp, #32]
174 ; CHECK-NEXT: stp q0, q0, [sp]
175 ; CHECK-NEXT: bl something
176 %buf = alloca [72 x i8], align 1
177 %cast = bitcast [72 x i8]* %buf to i8*
178 call void @llvm.memset.p0i8.i32(i8* %cast, i8 0, i32 72, i1 false)
179 call void @something(i8* %cast)
183 define void @bzero_128_stack() {
184 ; CHECK-LABEL: bzero_128_stack:
185 ; CHECK: movi v0.2d, #0000000000000000
186 ; CHECK-NEXT: mov x0, sp
187 ; CHECK-NEXT: stp q0, q0, [sp, #96]
188 ; CHECK-NEXT: stp q0, q0, [sp, #64]
189 ; CHECK-NEXT: stp q0, q0, [sp, #32]
190 ; CHECK-NEXT: stp q0, q0, [sp]
191 ; CHECK-NEXT: bl something
192 %buf = alloca [128 x i8], align 1
193 %cast = bitcast [128 x i8]* %buf to i8*
194 call void @llvm.memset.p0i8.i32(i8* %cast, i8 0, i32 128, i1 false)
195 call void @something(i8* %cast)
199 define void @bzero_256_stack() {
200 ; CHECK-LABEL: bzero_256_stack:
201 ; CHECK: movi v0.2d, #0000000000000000
202 ; CHECK-NEXT: mov x0, sp
203 ; CHECK-NEXT: stp q0, q0, [sp, #224]
204 ; CHECK-NEXT: stp q0, q0, [sp, #192]
205 ; CHECK-NEXT: stp q0, q0, [sp, #160]
206 ; CHECK-NEXT: stp q0, q0, [sp, #128]
207 ; CHECK-NEXT: stp q0, q0, [sp, #96]
208 ; CHECK-NEXT: stp q0, q0, [sp, #64]
209 ; CHECK-NEXT: stp q0, q0, [sp, #32]
210 ; CHECK-NEXT: stp q0, q0, [sp]
211 ; CHECK-NEXT: bl something
212 %buf = alloca [256 x i8], align 1
213 %cast = bitcast [256 x i8]* %buf to i8*
214 call void @llvm.memset.p0i8.i32(i8* %cast, i8 0, i32 256, i1 false)
215 call void @something(i8* %cast)
219 define void @memset_4_stack() {
220 ; CHECK-LABEL: memset_4_stack:
221 ; CHECK: mov w8, #-1431655766
222 ; CHECK-NEXT: add x0, sp, #12
223 ; CHECK-NEXT: str w8, [sp, #12]
224 ; CHECK-NEXT: bl something
225 %buf = alloca [4 x i8], align 1
226 %cast = bitcast [4 x i8]* %buf to i8*
227 call void @llvm.memset.p0i8.i32(i8* %cast, i8 -86, i32 4, i1 false)
228 call void @something(i8* %cast)
232 define void @memset_8_stack() {
233 ; CHECK-LABEL: memset_8_stack:
234 ; CHECK: mov x8, #-6148914691236517206
235 ; CHECK-NEXT: add x0, sp, #8
236 ; CHECK-NEXT: str x8, [sp, #8]
237 ; CHECK-NEXT: bl something
238 %buf = alloca [8 x i8], align 1
239 %cast = bitcast [8 x i8]* %buf to i8*
240 call void @llvm.memset.p0i8.i32(i8* %cast, i8 -86, i32 8, i1 false)
241 call void @something(i8* %cast)
245 define void @memset_12_stack() {
246 ; CHECK-LABEL: memset_12_stack:
247 ; CHECK: mov x8, #-6148914691236517206
248 ; CHECK-NEXT: mov x0, sp
249 ; CHECK-NEXT: str x8, [sp]
250 ; CHECK-NEXT: str w8, [sp, #8]
251 ; CHECK-NEXT: bl something
252 %buf = alloca [12 x i8], align 1
253 %cast = bitcast [12 x i8]* %buf to i8*
254 call void @llvm.memset.p0i8.i32(i8* %cast, i8 -86, i32 12, i1 false)
255 call void @something(i8* %cast)
259 define void @memset_16_stack() {
260 ; CHECK-LABEL: memset_16_stack:
261 ; CHECK: mov x8, #-6148914691236517206
262 ; CHECK-NEXT: mov x0, sp
263 ; CHECK-NEXT: stp x8, x30, [sp, #8]
264 ; CHECK-NEXT: str x8, [sp]
265 ; CHECK-NEXT: bl something
266 %buf = alloca [16 x i8], align 1
267 %cast = bitcast [16 x i8]* %buf to i8*
268 call void @llvm.memset.p0i8.i32(i8* %cast, i8 -86, i32 16, i1 false)
269 call void @something(i8* %cast)
273 define void @memset_20_stack() {
274 ; CHECK-LABEL: memset_20_stack:
275 ; CHECK: mov x8, #-6148914691236517206
276 ; CHECK-NEXT: add x0, sp, #8
277 ; CHECK-NEXT: stp x8, x8, [sp, #8]
278 ; CHECK-NEXT: str w8, [sp, #24]
279 ; CHECK-NEXT: bl something
280 %buf = alloca [20 x i8], align 1
281 %cast = bitcast [20 x i8]* %buf to i8*
282 call void @llvm.memset.p0i8.i32(i8* %cast, i8 -86, i32 20, i1 false)
283 call void @something(i8* %cast)
287 define void @memset_26_stack() {
288 ; CHECK-LABEL: memset_26_stack:
289 ; CHECK: mov x8, #-6148914691236517206
290 ; CHECK-NEXT: mov x0, sp
291 ; CHECK-NEXT: stp x8, x8, [sp, #8]
292 ; CHECK-NEXT: str x8, [sp]
293 ; CHECK-NEXT: strh w8, [sp, #24]
294 ; CHECK-NEXT: bl something
295 %buf = alloca [26 x i8], align 1
296 %cast = bitcast [26 x i8]* %buf to i8*
297 call void @llvm.memset.p0i8.i32(i8* %cast, i8 -86, i32 26, i1 false)
298 call void @something(i8* %cast)
302 define void @memset_32_stack() {
303 ; CHECK-LABEL: memset_32_stack:
304 ; CHECK: movi v0.16b, #170
305 ; CHECK-NEXT: mov x0, sp
306 ; CHECK-NEXT: stp q0, q0, [sp]
307 ; CHECK-NEXT: bl something
308 %buf = alloca [32 x i8], align 1
309 %cast = bitcast [32 x i8]* %buf to i8*
310 call void @llvm.memset.p0i8.i32(i8* %cast, i8 -86, i32 32, i1 false)
311 call void @something(i8* %cast)
315 define void @memset_40_stack() {
316 ; CHECK-LABEL: memset_40_stack:
317 ; CHECK: mov x8, #-6148914691236517206
318 ; CHECK-NEXT: movi v0.16b, #170
319 ; CHECK-NEXT: mov x0, sp
320 ; CHECK-NEXT: str x8, [sp, #32]
321 ; CHECK-NEXT: stp q0, q0, [sp]
322 ; CHECK-NEXT: bl something
323 %buf = alloca [40 x i8], align 1
324 %cast = bitcast [40 x i8]* %buf to i8*
325 call void @llvm.memset.p0i8.i32(i8* %cast, i8 -86, i32 40, i1 false)
326 call void @something(i8* %cast)
330 define void @memset_64_stack() {
331 ; CHECK-LABEL: memset_64_stack:
332 ; CHECK: movi v0.16b, #170
333 ; CHECK-NEXT: mov x0, sp
334 ; CHECK-NEXT: stp q0, q0, [sp, #32]
335 ; CHECK-NEXT: stp q0, q0, [sp]
336 ; CHECK-NEXT: bl something
337 %buf = alloca [64 x i8], align 1
338 %cast = bitcast [64 x i8]* %buf to i8*
339 call void @llvm.memset.p0i8.i32(i8* %cast, i8 -86, i32 64, i1 false)
340 call void @something(i8* %cast)
344 define void @memset_72_stack() {
345 ; CHECK-LABEL: memset_72_stack:
346 ; CHECK: mov x8, #-6148914691236517206
347 ; CHECK-NEXT: movi v0.16b, #170
348 ; CHECK-NEXT: mov x0, sp
349 ; CHECK-NEXT: str x8, [sp, #64]
350 ; CHECK-NEXT: stp q0, q0, [sp, #32]
351 ; CHECK-NEXT: stp q0, q0, [sp]
352 ; CHECK-NEXT: bl something
353 %buf = alloca [72 x i8], align 1
354 %cast = bitcast [72 x i8]* %buf to i8*
355 call void @llvm.memset.p0i8.i32(i8* %cast, i8 -86, i32 72, i1 false)
356 call void @something(i8* %cast)
360 define void @memset_128_stack() {
361 ; CHECK-LABEL: memset_128_stack:
362 ; CHECK: movi v0.16b, #170
363 ; CHECK-NEXT: mov x0, sp
364 ; CHECK-NEXT: stp q0, q0, [sp, #96]
365 ; CHECK-NEXT: stp q0, q0, [sp, #64]
366 ; CHECK-NEXT: stp q0, q0, [sp, #32]
367 ; CHECK-NEXT: stp q0, q0, [sp]
368 ; CHECK-NEXT: bl something
369 %buf = alloca [128 x i8], align 1
370 %cast = bitcast [128 x i8]* %buf to i8*
371 call void @llvm.memset.p0i8.i32(i8* %cast, i8 -86, i32 128, i1 false)
372 call void @something(i8* %cast)
376 define void @memset_256_stack() {
377 ; CHECK-LABEL: memset_256_stack:
378 ; CHECK: movi v0.16b, #170
379 ; CHECK-NEXT: mov x0, sp
380 ; CHECK-NEXT: stp q0, q0, [sp, #224]
381 ; CHECK-NEXT: stp q0, q0, [sp, #192]
382 ; CHECK-NEXT: stp q0, q0, [sp, #160]
383 ; CHECK-NEXT: stp q0, q0, [sp, #128]
384 ; CHECK-NEXT: stp q0, q0, [sp, #96]
385 ; CHECK-NEXT: stp q0, q0, [sp, #64]
386 ; CHECK-NEXT: stp q0, q0, [sp, #32]
387 ; CHECK-NEXT: stp q0, q0, [sp]
388 ; CHECK-NEXT: bl something
389 %buf = alloca [256 x i8], align 1
390 %cast = bitcast [256 x i8]* %buf to i8*
391 call void @llvm.memset.p0i8.i32(i8* %cast, i8 -86, i32 256, i1 false)
392 call void @something(i8* %cast)
396 declare void @something(i8*)
397 declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i1) nounwind
398 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) nounwind