arm64-indexed-memory.ll
15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
; RUN: llc < %s -mtriple=arm64-eabi -aarch64-redzone | FileCheck %s
; RUN: llc < %s -mtriple=arm64_32-apple-ios -aarch64-redzone | FileCheck %s
define i64* @store64(i64* %ptr, i64 %index, i64 %spacing) {
; CHECK-LABEL: store64:
; CHECK: str x{{[0-9+]}}, [x{{[0-9+]}}], #8
; CHECK: ret
%incdec.ptr = getelementptr inbounds i64, i64* %ptr, i64 1
store i64 %spacing, i64* %ptr, align 4
ret i64* %incdec.ptr
}
define i64* @store64idxpos256(i64* %ptr, i64 %index, i64 %spacing) {
; CHECK-LABEL: store64idxpos256:
; CHECK: add x{{[0-9+]}}, x{{[0-9+]}}, #256
; CHECK: str x{{[0-9+]}}, [x{{[0-9+]}}]
; CHECK: ret
%incdec.ptr = getelementptr inbounds i64, i64* %ptr, i64 32
store i64 %spacing, i64* %ptr, align 4
ret i64* %incdec.ptr
}
define i64* @store64idxneg256(i64* %ptr, i64 %index, i64 %spacing) {
; CHECK-LABEL: store64idxneg256:
; CHECK: str x{{[0-9+]}}, [x{{[0-9+]}}], #-256
; CHECK: ret
%incdec.ptr = getelementptr inbounds i64, i64* %ptr, i64 -32
store i64 %spacing, i64* %ptr, align 4
ret i64* %incdec.ptr
}
define i32* @store32(i32* %ptr, i32 %index, i32 %spacing) {
; CHECK-LABEL: store32:
; CHECK: str w{{[0-9+]}}, [x{{[0-9+]}}], #4
; CHECK: ret
%incdec.ptr = getelementptr inbounds i32, i32* %ptr, i64 1
store i32 %spacing, i32* %ptr, align 4
ret i32* %incdec.ptr
}
define i32* @store32idxpos256(i32* %ptr, i32 %index, i32 %spacing) {
; CHECK-LABEL: store32idxpos256:
; CHECK: add x{{[0-9+]}}, x{{[0-9+]}}, #256
; CHECK: str w{{[0-9+]}}, [x{{[0-9+]}}]
; CHECK: ret
%incdec.ptr = getelementptr inbounds i32, i32* %ptr, i64 64
store i32 %spacing, i32* %ptr, align 4
ret i32* %incdec.ptr
}
define i32* @store32idxneg256(i32* %ptr, i32 %index, i32 %spacing) {
; CHECK-LABEL: store32idxneg256:
; CHECK: str w{{[0-9+]}}, [x{{[0-9+]}}], #-256
; CHECK: ret
%incdec.ptr = getelementptr inbounds i32, i32* %ptr, i64 -64
store i32 %spacing, i32* %ptr, align 4
ret i32* %incdec.ptr
}
define i16* @store16(i16* %ptr, i16 %index, i16 %spacing) {
; CHECK-LABEL: store16:
; CHECK: strh w{{[0-9+]}}, [x{{[0-9+]}}], #2
; CHECK: ret
%incdec.ptr = getelementptr inbounds i16, i16* %ptr, i64 1
store i16 %spacing, i16* %ptr, align 4
ret i16* %incdec.ptr
}
define i16* @store16idxpos256(i16* %ptr, i16 %index, i16 %spacing) {
; CHECK-LABEL: store16idxpos256:
; CHECK: add x{{[0-9+]}}, x{{[0-9+]}}, #256
; CHECK: strh w{{[0-9+]}}, [x{{[0-9+]}}]
; CHECK: ret
%incdec.ptr = getelementptr inbounds i16, i16* %ptr, i64 128
store i16 %spacing, i16* %ptr, align 4
ret i16* %incdec.ptr
}
define i16* @store16idxneg256(i16* %ptr, i16 %index, i16 %spacing) {
; CHECK-LABEL: store16idxneg256:
; CHECK: strh w{{[0-9+]}}, [x{{[0-9+]}}], #-256
; CHECK: ret
%incdec.ptr = getelementptr inbounds i16, i16* %ptr, i64 -128
store i16 %spacing, i16* %ptr, align 4
ret i16* %incdec.ptr
}
define i8* @store8(i8* %ptr, i8 %index, i8 %spacing) {
; CHECK-LABEL: store8:
; CHECK: strb w{{[0-9+]}}, [x{{[0-9+]}}], #1
; CHECK: ret
%incdec.ptr = getelementptr inbounds i8, i8* %ptr, i64 1
store i8 %spacing, i8* %ptr, align 4
ret i8* %incdec.ptr
}
define i8* @store8idxpos256(i8* %ptr, i8 %index, i8 %spacing) {
; CHECK-LABEL: store8idxpos256:
; CHECK: add x{{[0-9+]}}, x{{[0-9+]}}, #256
; CHECK: strb w{{[0-9+]}}, [x{{[0-9+]}}]
; CHECK: ret
%incdec.ptr = getelementptr inbounds i8, i8* %ptr, i64 256
store i8 %spacing, i8* %ptr, align 4
ret i8* %incdec.ptr
}
define i8* @store8idxneg256(i8* %ptr, i8 %index, i8 %spacing) {
; CHECK-LABEL: store8idxneg256:
; CHECK: strb w{{[0-9+]}}, [x{{[0-9+]}}], #-256
; CHECK: ret
%incdec.ptr = getelementptr inbounds i8, i8* %ptr, i64 -256
store i8 %spacing, i8* %ptr, align 4
ret i8* %incdec.ptr
}
define i32* @truncst64to32(i32* %ptr, i32 %index, i64 %spacing) {
; CHECK-LABEL: truncst64to32:
; CHECK: str w{{[0-9+]}}, [x{{[0-9+]}}], #4
; CHECK: ret
%incdec.ptr = getelementptr inbounds i32, i32* %ptr, i64 1
%trunc = trunc i64 %spacing to i32
store i32 %trunc, i32* %ptr, align 4
ret i32* %incdec.ptr
}
define i16* @truncst64to16(i16* %ptr, i16 %index, i64 %spacing) {
; CHECK-LABEL: truncst64to16:
; CHECK: strh w{{[0-9+]}}, [x{{[0-9+]}}], #2
; CHECK: ret
%incdec.ptr = getelementptr inbounds i16, i16* %ptr, i64 1
%trunc = trunc i64 %spacing to i16
store i16 %trunc, i16* %ptr, align 4
ret i16* %incdec.ptr
}
define i8* @truncst64to8(i8* %ptr, i8 %index, i64 %spacing) {
; CHECK-LABEL: truncst64to8:
; CHECK: strb w{{[0-9+]}}, [x{{[0-9+]}}], #1
; CHECK: ret
%incdec.ptr = getelementptr inbounds i8, i8* %ptr, i64 1
%trunc = trunc i64 %spacing to i8
store i8 %trunc, i8* %ptr, align 4
ret i8* %incdec.ptr
}
define half* @storef16(half* %ptr, half %index, half %spacing) nounwind {
; CHECK-LABEL: storef16:
; CHECK: str h{{[0-9+]}}, [x{{[0-9+]}}], #2
; CHECK: ret
%incdec.ptr = getelementptr inbounds half, half* %ptr, i64 1
store half %spacing, half* %ptr, align 2
ret half* %incdec.ptr
}
define float* @storef32(float* %ptr, float %index, float %spacing) {
; CHECK-LABEL: storef32:
; CHECK: str s{{[0-9+]}}, [x{{[0-9+]}}], #4
; CHECK: ret
%incdec.ptr = getelementptr inbounds float, float* %ptr, i64 1
store float %spacing, float* %ptr, align 4
ret float* %incdec.ptr
}
define double* @storef64(double* %ptr, double %index, double %spacing) {
; CHECK-LABEL: storef64:
; CHECK: str d{{[0-9+]}}, [x{{[0-9+]}}], #8
; CHECK: ret
%incdec.ptr = getelementptr inbounds double, double* %ptr, i64 1
store double %spacing, double* %ptr, align 4
ret double* %incdec.ptr
}
define double* @pref64(double* %ptr, double %spacing) {
; CHECK-LABEL: pref64:
; CHECK: str d0, [x0, #32]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds double, double* %ptr, i64 4
store double %spacing, double* %incdec.ptr, align 4
ret double *%incdec.ptr
}
define float* @pref32(float* %ptr, float %spacing) {
; CHECK-LABEL: pref32:
; CHECK: str s0, [x0, #12]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds float, float* %ptr, i64 3
store float %spacing, float* %incdec.ptr, align 4
ret float *%incdec.ptr
}
define half* @pref16(half* %ptr, half %spacing) nounwind {
; CHECK-LABEL: pref16:
; CHECK: str h0, [x0, #6]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds half, half* %ptr, i64 3
store half %spacing, half* %incdec.ptr, align 2
ret half *%incdec.ptr
}
define i64* @pre64(i64* %ptr, i64 %spacing) {
; CHECK-LABEL: pre64:
; CHECK: str x1, [x0, #16]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i64, i64* %ptr, i64 2
store i64 %spacing, i64* %incdec.ptr, align 4
ret i64 *%incdec.ptr
}
define i64* @pre64idxpos256(i64* %ptr, i64 %spacing) {
; CHECK-LABEL: pre64idxpos256:
; CHECK: add x8, x0, #256
; CHECK-NEXT: str x1, [x0, #256]
; CHECK-NEXT: mov x0, x8
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i64, i64* %ptr, i64 32
store i64 %spacing, i64* %incdec.ptr, align 4
ret i64 *%incdec.ptr
}
define i64* @pre64idxneg256(i64* %ptr, i64 %spacing) {
; CHECK-LABEL: pre64idxneg256:
; CHECK: str x1, [x0, #-256]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i64, i64* %ptr, i64 -32
store i64 %spacing, i64* %incdec.ptr, align 4
ret i64 *%incdec.ptr
}
define i32* @pre32(i32* %ptr, i32 %spacing) {
; CHECK-LABEL: pre32:
; CHECK: str w1, [x0, #8]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i32, i32* %ptr, i64 2
store i32 %spacing, i32* %incdec.ptr, align 4
ret i32 *%incdec.ptr
}
define i32* @pre32idxpos256(i32* %ptr, i32 %spacing) {
; CHECK-LABEL: pre32idxpos256:
; CHECK: add x8, x0, #256
; CHECK-NEXT: str w1, [x0, #256]
; CHECK-NEXT: mov x0, x8
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i32, i32* %ptr, i64 64
store i32 %spacing, i32* %incdec.ptr, align 4
ret i32 *%incdec.ptr
}
define i32* @pre32idxneg256(i32* %ptr, i32 %spacing) {
; CHECK-LABEL: pre32idxneg256:
; CHECK: str w1, [x0, #-256]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i32, i32* %ptr, i64 -64
store i32 %spacing, i32* %incdec.ptr, align 4
ret i32 *%incdec.ptr
}
define i16* @pre16(i16* %ptr, i16 %spacing) {
; CHECK-LABEL: pre16:
; CHECK: strh w1, [x0, #4]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i16, i16* %ptr, i64 2
store i16 %spacing, i16* %incdec.ptr, align 4
ret i16 *%incdec.ptr
}
define i16* @pre16idxpos256(i16* %ptr, i16 %spacing) {
; CHECK-LABEL: pre16idxpos256:
; CHECK: add x8, x0, #256
; CHECK-NEXT: strh w1, [x0, #256]
; CHECK-NEXT: mov x0, x8
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i16, i16* %ptr, i64 128
store i16 %spacing, i16* %incdec.ptr, align 4
ret i16 *%incdec.ptr
}
define i16* @pre16idxneg256(i16* %ptr, i16 %spacing) {
; CHECK-LABEL: pre16idxneg256:
; CHECK: strh w1, [x0, #-256]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i16, i16* %ptr, i64 -128
store i16 %spacing, i16* %incdec.ptr, align 4
ret i16 *%incdec.ptr
}
define i8* @pre8(i8* %ptr, i8 %spacing) {
; CHECK-LABEL: pre8:
; CHECK: strb w1, [x0, #2]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i8, i8* %ptr, i64 2
store i8 %spacing, i8* %incdec.ptr, align 4
ret i8 *%incdec.ptr
}
define i8* @pre8idxpos256(i8* %ptr, i8 %spacing) {
; CHECK-LABEL: pre8idxpos256:
; CHECK: add x8, x0, #256
; CHECK-NEXT: strb w1, [x0, #256]
; CHECK-NEXT: mov x0, x8
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i8, i8* %ptr, i64 256
store i8 %spacing, i8* %incdec.ptr, align 4
ret i8 *%incdec.ptr
}
define i8* @pre8idxneg256(i8* %ptr, i8 %spacing) {
; CHECK-LABEL: pre8idxneg256:
; CHECK: strb w1, [x0, #-256]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i8, i8* %ptr, i64 -256
store i8 %spacing, i8* %incdec.ptr, align 4
ret i8 *%incdec.ptr
}
define i32* @pretrunc64to32(i32* %ptr, i64 %spacing) {
; CHECK-LABEL: pretrunc64to32:
; CHECK: str w1, [x0, #8]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i32, i32* %ptr, i64 2
%trunc = trunc i64 %spacing to i32
store i32 %trunc, i32* %incdec.ptr, align 4
ret i32 *%incdec.ptr
}
define i16* @pretrunc64to16(i16* %ptr, i64 %spacing) {
; CHECK-LABEL: pretrunc64to16:
; CHECK: strh w1, [x0, #4]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i16, i16* %ptr, i64 2
%trunc = trunc i64 %spacing to i16
store i16 %trunc, i16* %incdec.ptr, align 4
ret i16 *%incdec.ptr
}
define i8* @pretrunc64to8(i8* %ptr, i64 %spacing) {
; CHECK-LABEL: pretrunc64to8:
; CHECK: strb w1, [x0, #2]!
; CHECK-NEXT: ret
%incdec.ptr = getelementptr inbounds i8, i8* %ptr, i64 2
%trunc = trunc i64 %spacing to i8
store i8 %trunc, i8* %incdec.ptr, align 4
ret i8 *%incdec.ptr
}
;-----
; Pre-indexed loads
;-----
define double* @preidxf64(double* %src, double* %out) {
; CHECK-LABEL: preidxf64:
; CHECK: ldr d0, [x0, #8]!
; CHECK: str d0, [x1]
; CHECK: ret
%ptr = getelementptr inbounds double, double* %src, i64 1
%tmp = load double, double* %ptr, align 4
store double %tmp, double* %out, align 4
ret double* %ptr
}
define float* @preidxf32(float* %src, float* %out) {
; CHECK-LABEL: preidxf32:
; CHECK: ldr s0, [x0, #4]!
; CHECK: str s0, [x1]
; CHECK: ret
%ptr = getelementptr inbounds float, float* %src, i64 1
%tmp = load float, float* %ptr, align 4
store float %tmp, float* %out, align 4
ret float* %ptr
}
define half* @preidxf16(half* %src, half* %out) {
; CHECK-LABEL: preidxf16:
; CHECK: ldr h0, [x0, #2]!
; CHECK: str h0, [x1]
; CHECK: ret
%ptr = getelementptr inbounds half, half* %src, i64 1
%tmp = load half, half* %ptr, align 2
store half %tmp, half* %out, align 2
ret half* %ptr
}
define i64* @preidx64(i64* %src, i64* %out) {
; CHECK-LABEL: preidx64:
; CHECK: ldr x[[REG:[0-9]+]], [x0, #8]!
; CHECK: str x[[REG]], [x1]
; CHECK: ret
%ptr = getelementptr inbounds i64, i64* %src, i64 1
%tmp = load i64, i64* %ptr, align 4
store i64 %tmp, i64* %out, align 4
ret i64* %ptr
}
define i32* @preidx32(i32* %src, i32* %out) {
; CHECK: ldr w[[REG:[0-9]+]], [x0, #4]!
; CHECK: str w[[REG]], [x1]
; CHECK: ret
%ptr = getelementptr inbounds i32, i32* %src, i64 1
%tmp = load i32, i32* %ptr, align 4
store i32 %tmp, i32* %out, align 4
ret i32* %ptr
}
define i16* @preidx16zext32(i16* %src, i32* %out) {
; CHECK: ldrh w[[REG:[0-9]+]], [x0, #2]!
; CHECK: str w[[REG]], [x1]
; CHECK: ret
%ptr = getelementptr inbounds i16, i16* %src, i64 1
%tmp = load i16, i16* %ptr, align 4
%ext = zext i16 %tmp to i32
store i32 %ext, i32* %out, align 4
ret i16* %ptr
}
define i16* @preidx16zext64(i16* %src, i64* %out) {
; CHECK: ldrh w[[REG:[0-9]+]], [x0, #2]!
; CHECK: str x[[REG]], [x1]
; CHECK: ret
%ptr = getelementptr inbounds i16, i16* %src, i64 1
%tmp = load i16, i16* %ptr, align 4
%ext = zext i16 %tmp to i64
store i64 %ext, i64* %out, align 4
ret i16* %ptr
}
define i8* @preidx8zext32(i8* %src, i32* %out) {
; CHECK: ldrb w[[REG:[0-9]+]], [x0, #1]!
; CHECK: str w[[REG]], [x1]
; CHECK: ret
%ptr = getelementptr inbounds i8, i8* %src, i64 1
%tmp = load i8, i8* %ptr, align 4
%ext = zext i8 %tmp to i32
store i32 %ext, i32* %out, align 4
ret i8* %ptr
}
define i8* @preidx8zext64(i8* %src, i64* %out) {
; CHECK: ldrb w[[REG:[0-9]+]], [x0, #1]!
; CHECK: str x[[REG]], [x1]
; CHECK: ret
%ptr = getelementptr inbounds i8, i8* %src, i64 1
%tmp = load i8, i8* %ptr, align 4
%ext = zext i8 %tmp to i64
store i64 %ext, i64* %out, align 4
ret i8* %ptr
}
define i32* @preidx32sext64(i32* %src, i64* %out) {
; CHECK: ldrsw x[[REG:[0-9]+]], [x0, #4]!
; CHECK: str x[[REG]], [x1]
; CHECK: ret
%ptr = getelementptr inbounds i32, i32* %src, i64 1
%tmp = load i32, i32* %ptr, align 4
%ext = sext i32 %tmp to i64
store i64 %ext, i64* %out, align 8
ret i32* %ptr
}
define i16* @preidx16sext32(i16* %src, i32* %out) {
; CHECK: ldrsh w[[REG:[0-9]+]], [x0, #2]!
; CHECK: str w[[REG]], [x1]
; CHECK: ret
%ptr = getelementptr inbounds i16, i16* %src, i64 1
%tmp = load i16, i16* %ptr, align 4
%ext = sext i16 %tmp to i32
store i32 %ext, i32* %out, align 4
ret i16* %ptr
}
define i16* @preidx16sext64(i16* %src, i64* %out) {
; CHECK: ldrsh x[[REG:[0-9]+]], [x0, #2]!
; CHECK: str x[[REG]], [x1]
; CHECK: ret
%ptr = getelementptr inbounds i16, i16* %src, i64 1
%tmp = load i16, i16* %ptr, align 4
%ext = sext i16 %tmp to i64
store i64 %ext, i64* %out, align 4
ret i16* %ptr
}
define i8* @preidx8sext32(i8* %src, i32* %out) {
; CHECK: ldrsb w[[REG:[0-9]+]], [x0, #1]!
; CHECK: str w[[REG]], [x1]
; CHECK: ret
%ptr = getelementptr inbounds i8, i8* %src, i64 1
%tmp = load i8, i8* %ptr, align 4
%ext = sext i8 %tmp to i32
store i32 %ext, i32* %out, align 4
ret i8* %ptr
}
define i8* @preidx8sext64(i8* %src, i64* %out) {
; CHECK: ldrsb x[[REG:[0-9]+]], [x0, #1]!
; CHECK: str x[[REG]], [x1]
; CHECK: ret
%ptr = getelementptr inbounds i8, i8* %src, i64 1
%tmp = load i8, i8* %ptr, align 4
%ext = sext i8 %tmp to i64
store i64 %ext, i64* %out, align 4
ret i8* %ptr
}
; This test checks if illegal post-index is generated
define i64* @postidx_clobber(i64* %addr) nounwind noinline ssp {
; CHECK-LABEL: postidx_clobber:
; CHECK-NOT: str x0, [x0], #8
; ret
%paddr = bitcast i64* %addr to i64**
store i64* %addr, i64** %paddr
%newaddr = getelementptr i64, i64* %addr, i32 1
ret i64* %newaddr
}