• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -march=arm64 -aarch64-redzone | FileCheck %s
2
3define void @store64(i64** nocapture %out, i64 %index, i64 %spacing) nounwind noinline ssp {
4; CHECK-LABEL: store64:
5; CHECK: str x{{[0-9+]}}, [x{{[0-9+]}}], #8
6; CHECK: ret
7  %tmp = load i64*, i64** %out, align 8
8  %incdec.ptr = getelementptr inbounds i64, i64* %tmp, i64 1
9  store i64 %spacing, i64* %tmp, align 4
10  store i64* %incdec.ptr, i64** %out, align 8
11  ret void
12}
13
14define void @store32(i32** nocapture %out, i32 %index, i32 %spacing) nounwind noinline ssp {
15; CHECK-LABEL: store32:
16; CHECK: str w{{[0-9+]}}, [x{{[0-9+]}}], #4
17; CHECK: ret
18  %tmp = load i32*, i32** %out, align 8
19  %incdec.ptr = getelementptr inbounds i32, i32* %tmp, i64 1
20  store i32 %spacing, i32* %tmp, align 4
21  store i32* %incdec.ptr, i32** %out, align 8
22  ret void
23}
24
25define void @store16(i16** nocapture %out, i16 %index, i16 %spacing) nounwind noinline ssp {
26; CHECK-LABEL: store16:
27; CHECK: strh w{{[0-9+]}}, [x{{[0-9+]}}], #2
28; CHECK: ret
29  %tmp = load i16*, i16** %out, align 8
30  %incdec.ptr = getelementptr inbounds i16, i16* %tmp, i64 1
31  store i16 %spacing, i16* %tmp, align 4
32  store i16* %incdec.ptr, i16** %out, align 8
33  ret void
34}
35
36define void @store8(i8** nocapture %out, i8 %index, i8 %spacing) nounwind noinline ssp {
37; CHECK-LABEL: store8:
38; CHECK: strb w{{[0-9+]}}, [x{{[0-9+]}}], #1
39; CHECK: ret
40  %tmp = load i8*, i8** %out, align 8
41  %incdec.ptr = getelementptr inbounds i8, i8* %tmp, i64 1
42  store i8 %spacing, i8* %tmp, align 4
43  store i8* %incdec.ptr, i8** %out, align 8
44  ret void
45}
46
47define void @truncst64to32(i32** nocapture %out, i32 %index, i64 %spacing) nounwind noinline ssp {
48; CHECK-LABEL: truncst64to32:
49; CHECK: str w{{[0-9+]}}, [x{{[0-9+]}}], #4
50; CHECK: ret
51  %tmp = load i32*, i32** %out, align 8
52  %incdec.ptr = getelementptr inbounds i32, i32* %tmp, i64 1
53  %trunc = trunc i64 %spacing to i32
54  store i32 %trunc, i32* %tmp, align 4
55  store i32* %incdec.ptr, i32** %out, align 8
56  ret void
57}
58
59define void @truncst64to16(i16** nocapture %out, i16 %index, i64 %spacing) nounwind noinline ssp {
60; CHECK-LABEL: truncst64to16:
61; CHECK: strh w{{[0-9+]}}, [x{{[0-9+]}}], #2
62; CHECK: ret
63  %tmp = load i16*, i16** %out, align 8
64  %incdec.ptr = getelementptr inbounds i16, i16* %tmp, i64 1
65  %trunc = trunc i64 %spacing to i16
66  store i16 %trunc, i16* %tmp, align 4
67  store i16* %incdec.ptr, i16** %out, align 8
68  ret void
69}
70
71define void @truncst64to8(i8** nocapture %out, i8 %index, i64 %spacing) nounwind noinline ssp {
72; CHECK-LABEL: truncst64to8:
73; CHECK: strb w{{[0-9+]}}, [x{{[0-9+]}}], #1
74; CHECK: ret
75  %tmp = load i8*, i8** %out, align 8
76  %incdec.ptr = getelementptr inbounds i8, i8* %tmp, i64 1
77  %trunc = trunc i64 %spacing to i8
78  store i8 %trunc, i8* %tmp, align 4
79  store i8* %incdec.ptr, i8** %out, align 8
80  ret void
81}
82
83
84define void @storef32(float** nocapture %out, float %index, float %spacing) nounwind noinline ssp {
85; CHECK-LABEL: storef32:
86; CHECK: str s{{[0-9+]}}, [x{{[0-9+]}}], #4
87; CHECK: ret
88  %tmp = load float*, float** %out, align 8
89  %incdec.ptr = getelementptr inbounds float, float* %tmp, i64 1
90  store float %spacing, float* %tmp, align 4
91  store float* %incdec.ptr, float** %out, align 8
92  ret void
93}
94
95define void @storef64(double** nocapture %out, double %index, double %spacing) nounwind noinline ssp {
96; CHECK-LABEL: storef64:
97; CHECK: str d{{[0-9+]}}, [x{{[0-9+]}}], #8
98; CHECK: ret
99  %tmp = load double*, double** %out, align 8
100  %incdec.ptr = getelementptr inbounds double, double* %tmp, i64 1
101  store double %spacing, double* %tmp, align 4
102  store double* %incdec.ptr, double** %out, align 8
103  ret void
104}
105
106define double * @pref64(double** nocapture %out, double %spacing) nounwind noinline ssp {
107; CHECK-LABEL: pref64:
108; CHECK: ldr     x0, [x0]
109; CHECK-NEXT: str     d0, [x0, #32]!
110; CHECK-NEXT: ret
111  %tmp = load double*, double** %out, align 8
112  %ptr = getelementptr inbounds double, double* %tmp, i64 4
113  store double %spacing, double* %ptr, align 4
114  ret double *%ptr
115}
116
117define float * @pref32(float** nocapture %out, float %spacing) nounwind noinline ssp {
118; CHECK-LABEL: pref32:
119; CHECK: ldr     x0, [x0]
120; CHECK-NEXT: str     s0, [x0, #12]!
121; CHECK-NEXT: ret
122  %tmp = load float*, float** %out, align 8
123  %ptr = getelementptr inbounds float, float* %tmp, i64 3
124  store float %spacing, float* %ptr, align 4
125  ret float *%ptr
126}
127
128define i64 * @pre64(i64** nocapture %out, i64 %spacing) nounwind noinline ssp {
129; CHECK-LABEL: pre64:
130; CHECK: ldr     x0, [x0]
131; CHECK-NEXT: str     x1, [x0, #16]!
132; CHECK-NEXT: ret
133  %tmp = load i64*, i64** %out, align 8
134  %ptr = getelementptr inbounds i64, i64* %tmp, i64 2
135  store i64 %spacing, i64* %ptr, align 4
136  ret i64 *%ptr
137}
138
139define i32 * @pre32(i32** nocapture %out, i32 %spacing) nounwind noinline ssp {
140; CHECK-LABEL: pre32:
141; CHECK: ldr     x0, [x0]
142; CHECK-NEXT: str     w1, [x0, #8]!
143; CHECK-NEXT: ret
144  %tmp = load i32*, i32** %out, align 8
145  %ptr = getelementptr inbounds i32, i32* %tmp, i64 2
146  store i32 %spacing, i32* %ptr, align 4
147  ret i32 *%ptr
148}
149
150define i16 * @pre16(i16** nocapture %out, i16 %spacing) nounwind noinline ssp {
151; CHECK-LABEL: pre16:
152; CHECK: ldr     x0, [x0]
153; CHECK-NEXT: strh    w1, [x0, #4]!
154; CHECK-NEXT: ret
155  %tmp = load i16*, i16** %out, align 8
156  %ptr = getelementptr inbounds i16, i16* %tmp, i64 2
157  store i16 %spacing, i16* %ptr, align 4
158  ret i16 *%ptr
159}
160
161define i8 * @pre8(i8** nocapture %out, i8 %spacing) nounwind noinline ssp {
162; CHECK-LABEL: pre8:
163; CHECK: ldr     x0, [x0]
164; CHECK-NEXT: strb    w1, [x0, #2]!
165; CHECK-NEXT: ret
166  %tmp = load i8*, i8** %out, align 8
167  %ptr = getelementptr inbounds i8, i8* %tmp, i64 2
168  store i8 %spacing, i8* %ptr, align 4
169  ret i8 *%ptr
170}
171
172define i32 * @pretrunc64to32(i32** nocapture %out, i64 %spacing) nounwind noinline ssp {
173; CHECK-LABEL: pretrunc64to32:
174; CHECK: ldr     x0, [x0]
175; CHECK-NEXT: str     w1, [x0, #8]!
176; CHECK-NEXT: ret
177  %tmp = load i32*, i32** %out, align 8
178  %ptr = getelementptr inbounds i32, i32* %tmp, i64 2
179  %trunc = trunc i64 %spacing to i32
180  store i32 %trunc, i32* %ptr, align 4
181  ret i32 *%ptr
182}
183
184define i16 * @pretrunc64to16(i16** nocapture %out, i64 %spacing) nounwind noinline ssp {
185; CHECK-LABEL: pretrunc64to16:
186; CHECK: ldr     x0, [x0]
187; CHECK-NEXT: strh    w1, [x0, #4]!
188; CHECK-NEXT: ret
189  %tmp = load i16*, i16** %out, align 8
190  %ptr = getelementptr inbounds i16, i16* %tmp, i64 2
191  %trunc = trunc i64 %spacing to i16
192  store i16 %trunc, i16* %ptr, align 4
193  ret i16 *%ptr
194}
195
196define i8 * @pretrunc64to8(i8** nocapture %out, i64 %spacing) nounwind noinline ssp {
197; CHECK-LABEL: pretrunc64to8:
198; CHECK: ldr     x0, [x0]
199; CHECK-NEXT: strb    w1, [x0, #2]!
200; CHECK-NEXT: ret
201  %tmp = load i8*, i8** %out, align 8
202  %ptr = getelementptr inbounds i8, i8* %tmp, i64 2
203  %trunc = trunc i64 %spacing to i8
204  store i8 %trunc, i8* %ptr, align 4
205  ret i8 *%ptr
206}
207
208;-----
209; Pre-indexed loads
210;-----
211define double* @preidxf64(double* %src, double* %out) {
212; CHECK-LABEL: preidxf64:
213; CHECK: ldr     d0, [x0, #8]!
214; CHECK: str     d0, [x1]
215; CHECK: ret
216  %ptr = getelementptr inbounds double, double* %src, i64 1
217  %tmp = load double, double* %ptr, align 4
218  store double %tmp, double* %out, align 4
219  ret double* %ptr
220}
221
222define float* @preidxf32(float* %src, float* %out) {
223; CHECK-LABEL: preidxf32:
224; CHECK: ldr     s0, [x0, #4]!
225; CHECK: str     s0, [x1]
226; CHECK: ret
227  %ptr = getelementptr inbounds float, float* %src, i64 1
228  %tmp = load float, float* %ptr, align 4
229  store float %tmp, float* %out, align 4
230  ret float* %ptr
231}
232
233define i64* @preidx64(i64* %src, i64* %out) {
234; CHECK-LABEL: preidx64:
235; CHECK: ldr     x[[REG:[0-9]+]], [x0, #8]!
236; CHECK: str     x[[REG]], [x1]
237; CHECK: ret
238  %ptr = getelementptr inbounds i64, i64* %src, i64 1
239  %tmp = load i64, i64* %ptr, align 4
240  store i64 %tmp, i64* %out, align 4
241  ret i64* %ptr
242}
243
244define i32* @preidx32(i32* %src, i32* %out) {
245; CHECK: ldr     w[[REG:[0-9]+]], [x0, #4]!
246; CHECK: str     w[[REG]], [x1]
247; CHECK: ret
248  %ptr = getelementptr inbounds i32, i32* %src, i64 1
249  %tmp = load i32, i32* %ptr, align 4
250  store i32 %tmp, i32* %out, align 4
251  ret i32* %ptr
252}
253
254define i16* @preidx16zext32(i16* %src, i32* %out) {
255; CHECK: ldrh    w[[REG:[0-9]+]], [x0, #2]!
256; CHECK: str     w[[REG]], [x1]
257; CHECK: ret
258  %ptr = getelementptr inbounds i16, i16* %src, i64 1
259  %tmp = load i16, i16* %ptr, align 4
260  %ext = zext i16 %tmp to i32
261  store i32 %ext, i32* %out, align 4
262  ret i16* %ptr
263}
264
265define i16* @preidx16zext64(i16* %src, i64* %out) {
266; CHECK: ldrh    w[[REG:[0-9]+]], [x0, #2]!
267; CHECK: str     x[[REG]], [x1]
268; CHECK: ret
269  %ptr = getelementptr inbounds i16, i16* %src, i64 1
270  %tmp = load i16, i16* %ptr, align 4
271  %ext = zext i16 %tmp to i64
272  store i64 %ext, i64* %out, align 4
273  ret i16* %ptr
274}
275
276define i8* @preidx8zext32(i8* %src, i32* %out) {
277; CHECK: ldrb    w[[REG:[0-9]+]], [x0, #1]!
278; CHECK: str     w[[REG]], [x1]
279; CHECK: ret
280  %ptr = getelementptr inbounds i8, i8* %src, i64 1
281  %tmp = load i8, i8* %ptr, align 4
282  %ext = zext i8 %tmp to i32
283  store i32 %ext, i32* %out, align 4
284  ret i8* %ptr
285}
286
287define i8* @preidx8zext64(i8* %src, i64* %out) {
288; CHECK: ldrb    w[[REG:[0-9]+]], [x0, #1]!
289; CHECK: str     x[[REG]], [x1]
290; CHECK: ret
291  %ptr = getelementptr inbounds i8, i8* %src, i64 1
292  %tmp = load i8, i8* %ptr, align 4
293  %ext = zext i8 %tmp to i64
294  store i64 %ext, i64* %out, align 4
295  ret i8* %ptr
296}
297
298define i32* @preidx32sext64(i32* %src, i64* %out) {
299; CHECK: ldrsw   x[[REG:[0-9]+]], [x0, #4]!
300; CHECK: str     x[[REG]], [x1]
301; CHECK: ret
302  %ptr = getelementptr inbounds i32, i32* %src, i64 1
303  %tmp = load i32, i32* %ptr, align 4
304  %ext = sext i32 %tmp to i64
305  store i64 %ext, i64* %out, align 8
306  ret i32* %ptr
307}
308
309define i16* @preidx16sext32(i16* %src, i32* %out) {
310; CHECK: ldrsh   w[[REG:[0-9]+]], [x0, #2]!
311; CHECK: str     w[[REG]], [x1]
312; CHECK: ret
313  %ptr = getelementptr inbounds i16, i16* %src, i64 1
314  %tmp = load i16, i16* %ptr, align 4
315  %ext = sext i16 %tmp to i32
316  store i32 %ext, i32* %out, align 4
317  ret i16* %ptr
318}
319
320define i16* @preidx16sext64(i16* %src, i64* %out) {
321; CHECK: ldrsh   x[[REG:[0-9]+]], [x0, #2]!
322; CHECK: str     x[[REG]], [x1]
323; CHECK: ret
324  %ptr = getelementptr inbounds i16, i16* %src, i64 1
325  %tmp = load i16, i16* %ptr, align 4
326  %ext = sext i16 %tmp to i64
327  store i64 %ext, i64* %out, align 4
328  ret i16* %ptr
329}
330
331define i8* @preidx8sext32(i8* %src, i32* %out) {
332; CHECK: ldrsb   w[[REG:[0-9]+]], [x0, #1]!
333; CHECK: str     w[[REG]], [x1]
334; CHECK: ret
335  %ptr = getelementptr inbounds i8, i8* %src, i64 1
336  %tmp = load i8, i8* %ptr, align 4
337  %ext = sext i8 %tmp to i32
338  store i32 %ext, i32* %out, align 4
339  ret i8* %ptr
340}
341
342define i8* @preidx8sext64(i8* %src, i64* %out) {
343; CHECK: ldrsb   x[[REG:[0-9]+]], [x0, #1]!
344; CHECK: str     x[[REG]], [x1]
345; CHECK: ret
346  %ptr = getelementptr inbounds i8, i8* %src, i64 1
347  %tmp = load i8, i8* %ptr, align 4
348  %ext = sext i8 %tmp to i64
349  store i64 %ext, i64* %out, align 4
350  ret i8* %ptr
351}
352
353; This test checks if illegal post-index is generated
354
355define i64* @postidx_clobber(i64* %addr) nounwind noinline ssp {
356; CHECK-LABEL: postidx_clobber:
357; CHECK-NOT: str     x0, [x0], #8
358; ret
359 %paddr = bitcast i64* %addr to i64**
360 store i64* %addr, i64** %paddr
361 %newaddr = getelementptr i64, i64* %addr, i32 1
362 ret i64* %newaddr
363}
364