blob: b6ab9934dbc3af2c978ac4e59210897a87730467 [file] [log] [blame]
Tim Northover3b0846e2014-05-24 12:50:23 +00001; 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
David Blaikiea79ac142015-02-27 21:17:42 +00007 %tmp = load i64*, i64** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +00008 %incdec.ptr = getelementptr inbounds i64, i64* %tmp, i64 1
Tim Northover3b0846e2014-05-24 12:50:23 +00009 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
David Blaikiea79ac142015-02-27 21:17:42 +000018 %tmp = load i32*, i32** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +000019 %incdec.ptr = getelementptr inbounds i32, i32* %tmp, i64 1
Tim Northover3b0846e2014-05-24 12:50:23 +000020 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
David Blaikiea79ac142015-02-27 21:17:42 +000029 %tmp = load i16*, i16** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +000030 %incdec.ptr = getelementptr inbounds i16, i16* %tmp, i64 1
Tim Northover3b0846e2014-05-24 12:50:23 +000031 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
David Blaikiea79ac142015-02-27 21:17:42 +000040 %tmp = load i8*, i8** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +000041 %incdec.ptr = getelementptr inbounds i8, i8* %tmp, i64 1
Tim Northover3b0846e2014-05-24 12:50:23 +000042 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
David Blaikiea79ac142015-02-27 21:17:42 +000051 %tmp = load i32*, i32** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +000052 %incdec.ptr = getelementptr inbounds i32, i32* %tmp, i64 1
Tim Northover3b0846e2014-05-24 12:50:23 +000053 %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
David Blaikiea79ac142015-02-27 21:17:42 +000063 %tmp = load i16*, i16** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +000064 %incdec.ptr = getelementptr inbounds i16, i16* %tmp, i64 1
Tim Northover3b0846e2014-05-24 12:50:23 +000065 %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
David Blaikiea79ac142015-02-27 21:17:42 +000075 %tmp = load i8*, i8** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +000076 %incdec.ptr = getelementptr inbounds i8, i8* %tmp, i64 1
Tim Northover3b0846e2014-05-24 12:50:23 +000077 %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
Ahmed Bougachae0e12db2015-08-04 01:29:38 +000084define void @storef16(half** %out, half %index, half %spacing) nounwind {
85; CHECK-LABEL: storef16:
86; CHECK: str h{{[0-9+]}}, [x{{[0-9+]}}], #2
87; CHECK: ret
88 %tmp = load half*, half** %out, align 2
89 %incdec.ptr = getelementptr inbounds half, half* %tmp, i64 1
90 store half %spacing, half* %tmp, align 2
91 store half* %incdec.ptr, half** %out, align 2
92 ret void
93}
94
Tim Northover3b0846e2014-05-24 12:50:23 +000095define void @storef32(float** nocapture %out, float %index, float %spacing) nounwind noinline ssp {
96; CHECK-LABEL: storef32:
97; CHECK: str s{{[0-9+]}}, [x{{[0-9+]}}], #4
98; CHECK: ret
David Blaikiea79ac142015-02-27 21:17:42 +000099 %tmp = load float*, float** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +0000100 %incdec.ptr = getelementptr inbounds float, float* %tmp, i64 1
Tim Northover3b0846e2014-05-24 12:50:23 +0000101 store float %spacing, float* %tmp, align 4
102 store float* %incdec.ptr, float** %out, align 8
103 ret void
104}
105
106define void @storef64(double** nocapture %out, double %index, double %spacing) nounwind noinline ssp {
107; CHECK-LABEL: storef64:
108; CHECK: str d{{[0-9+]}}, [x{{[0-9+]}}], #8
109; CHECK: ret
David Blaikiea79ac142015-02-27 21:17:42 +0000110 %tmp = load double*, double** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +0000111 %incdec.ptr = getelementptr inbounds double, double* %tmp, i64 1
Tim Northover3b0846e2014-05-24 12:50:23 +0000112 store double %spacing, double* %tmp, align 4
113 store double* %incdec.ptr, double** %out, align 8
114 ret void
115}
116
117define double * @pref64(double** nocapture %out, double %spacing) nounwind noinline ssp {
118; CHECK-LABEL: pref64:
119; CHECK: ldr x0, [x0]
120; CHECK-NEXT: str d0, [x0, #32]!
121; CHECK-NEXT: ret
David Blaikiea79ac142015-02-27 21:17:42 +0000122 %tmp = load double*, double** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +0000123 %ptr = getelementptr inbounds double, double* %tmp, i64 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000124 store double %spacing, double* %ptr, align 4
125 ret double *%ptr
126}
127
128define float * @pref32(float** nocapture %out, float %spacing) nounwind noinline ssp {
129; CHECK-LABEL: pref32:
130; CHECK: ldr x0, [x0]
131; CHECK-NEXT: str s0, [x0, #12]!
132; CHECK-NEXT: ret
David Blaikiea79ac142015-02-27 21:17:42 +0000133 %tmp = load float*, float** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +0000134 %ptr = getelementptr inbounds float, float* %tmp, i64 3
Tim Northover3b0846e2014-05-24 12:50:23 +0000135 store float %spacing, float* %ptr, align 4
136 ret float *%ptr
137}
138
Ahmed Bougachae0e12db2015-08-04 01:29:38 +0000139define half* @pref16(half** %out, half %spacing) nounwind {
140; CHECK-LABEL: pref16:
141; CHECK: ldr x0, [x0]
142; CHECK-NEXT: str h0, [x0, #6]!
143; CHECK-NEXT: ret
144 %tmp = load half*, half** %out, align 2
145 %ptr = getelementptr inbounds half, half* %tmp, i64 3
146 store half %spacing, half* %ptr, align 2
147 ret half *%ptr
148}
149
Tim Northover3b0846e2014-05-24 12:50:23 +0000150define i64 * @pre64(i64** nocapture %out, i64 %spacing) nounwind noinline ssp {
151; CHECK-LABEL: pre64:
152; CHECK: ldr x0, [x0]
153; CHECK-NEXT: str x1, [x0, #16]!
154; CHECK-NEXT: ret
David Blaikiea79ac142015-02-27 21:17:42 +0000155 %tmp = load i64*, i64** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +0000156 %ptr = getelementptr inbounds i64, i64* %tmp, i64 2
Tim Northover3b0846e2014-05-24 12:50:23 +0000157 store i64 %spacing, i64* %ptr, align 4
158 ret i64 *%ptr
159}
160
161define i32 * @pre32(i32** nocapture %out, i32 %spacing) nounwind noinline ssp {
162; CHECK-LABEL: pre32:
163; CHECK: ldr x0, [x0]
164; CHECK-NEXT: str w1, [x0, #8]!
165; CHECK-NEXT: ret
David Blaikiea79ac142015-02-27 21:17:42 +0000166 %tmp = load i32*, i32** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +0000167 %ptr = getelementptr inbounds i32, i32* %tmp, i64 2
Tim Northover3b0846e2014-05-24 12:50:23 +0000168 store i32 %spacing, i32* %ptr, align 4
169 ret i32 *%ptr
170}
171
172define i16 * @pre16(i16** nocapture %out, i16 %spacing) nounwind noinline ssp {
173; CHECK-LABEL: pre16:
174; CHECK: ldr x0, [x0]
175; CHECK-NEXT: strh w1, [x0, #4]!
176; CHECK-NEXT: ret
David Blaikiea79ac142015-02-27 21:17:42 +0000177 %tmp = load i16*, i16** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +0000178 %ptr = getelementptr inbounds i16, i16* %tmp, i64 2
Tim Northover3b0846e2014-05-24 12:50:23 +0000179 store i16 %spacing, i16* %ptr, align 4
180 ret i16 *%ptr
181}
182
183define i8 * @pre8(i8** nocapture %out, i8 %spacing) nounwind noinline ssp {
184; CHECK-LABEL: pre8:
185; CHECK: ldr x0, [x0]
186; CHECK-NEXT: strb w1, [x0, #2]!
187; CHECK-NEXT: ret
David Blaikiea79ac142015-02-27 21:17:42 +0000188 %tmp = load i8*, i8** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +0000189 %ptr = getelementptr inbounds i8, i8* %tmp, i64 2
Tim Northover3b0846e2014-05-24 12:50:23 +0000190 store i8 %spacing, i8* %ptr, align 4
191 ret i8 *%ptr
192}
193
194define i32 * @pretrunc64to32(i32** nocapture %out, i64 %spacing) nounwind noinline ssp {
195; CHECK-LABEL: pretrunc64to32:
196; CHECK: ldr x0, [x0]
197; CHECK-NEXT: str w1, [x0, #8]!
198; CHECK-NEXT: ret
David Blaikiea79ac142015-02-27 21:17:42 +0000199 %tmp = load i32*, i32** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +0000200 %ptr = getelementptr inbounds i32, i32* %tmp, i64 2
Tim Northover3b0846e2014-05-24 12:50:23 +0000201 %trunc = trunc i64 %spacing to i32
202 store i32 %trunc, i32* %ptr, align 4
203 ret i32 *%ptr
204}
205
206define i16 * @pretrunc64to16(i16** nocapture %out, i64 %spacing) nounwind noinline ssp {
207; CHECK-LABEL: pretrunc64to16:
208; CHECK: ldr x0, [x0]
209; CHECK-NEXT: strh w1, [x0, #4]!
210; CHECK-NEXT: ret
David Blaikiea79ac142015-02-27 21:17:42 +0000211 %tmp = load i16*, i16** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +0000212 %ptr = getelementptr inbounds i16, i16* %tmp, i64 2
Tim Northover3b0846e2014-05-24 12:50:23 +0000213 %trunc = trunc i64 %spacing to i16
214 store i16 %trunc, i16* %ptr, align 4
215 ret i16 *%ptr
216}
217
218define i8 * @pretrunc64to8(i8** nocapture %out, i64 %spacing) nounwind noinline ssp {
219; CHECK-LABEL: pretrunc64to8:
220; CHECK: ldr x0, [x0]
221; CHECK-NEXT: strb w1, [x0, #2]!
222; CHECK-NEXT: ret
David Blaikiea79ac142015-02-27 21:17:42 +0000223 %tmp = load i8*, i8** %out, align 8
David Blaikie79e6c742015-02-27 19:29:02 +0000224 %ptr = getelementptr inbounds i8, i8* %tmp, i64 2
Tim Northover3b0846e2014-05-24 12:50:23 +0000225 %trunc = trunc i64 %spacing to i8
226 store i8 %trunc, i8* %ptr, align 4
227 ret i8 *%ptr
228}
229
230;-----
231; Pre-indexed loads
232;-----
233define double* @preidxf64(double* %src, double* %out) {
234; CHECK-LABEL: preidxf64:
235; CHECK: ldr d0, [x0, #8]!
236; CHECK: str d0, [x1]
237; CHECK: ret
David Blaikie79e6c742015-02-27 19:29:02 +0000238 %ptr = getelementptr inbounds double, double* %src, i64 1
David Blaikiea79ac142015-02-27 21:17:42 +0000239 %tmp = load double, double* %ptr, align 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000240 store double %tmp, double* %out, align 4
241 ret double* %ptr
242}
243
244define float* @preidxf32(float* %src, float* %out) {
245; CHECK-LABEL: preidxf32:
246; CHECK: ldr s0, [x0, #4]!
247; CHECK: str s0, [x1]
248; CHECK: ret
David Blaikie79e6c742015-02-27 19:29:02 +0000249 %ptr = getelementptr inbounds float, float* %src, i64 1
David Blaikiea79ac142015-02-27 21:17:42 +0000250 %tmp = load float, float* %ptr, align 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000251 store float %tmp, float* %out, align 4
252 ret float* %ptr
253}
254
Ahmed Bougachae0e12db2015-08-04 01:29:38 +0000255define half* @preidxf16(half* %src, half* %out) {
256; CHECK-LABEL: preidxf16:
257; CHECK: ldr h0, [x0, #2]!
258; CHECK: str h0, [x1]
259; CHECK: ret
260 %ptr = getelementptr inbounds half, half* %src, i64 1
261 %tmp = load half, half* %ptr, align 2
262 store half %tmp, half* %out, align 2
263 ret half* %ptr
264}
265
Tim Northover3b0846e2014-05-24 12:50:23 +0000266define i64* @preidx64(i64* %src, i64* %out) {
267; CHECK-LABEL: preidx64:
268; CHECK: ldr x[[REG:[0-9]+]], [x0, #8]!
269; CHECK: str x[[REG]], [x1]
270; CHECK: ret
David Blaikie79e6c742015-02-27 19:29:02 +0000271 %ptr = getelementptr inbounds i64, i64* %src, i64 1
David Blaikiea79ac142015-02-27 21:17:42 +0000272 %tmp = load i64, i64* %ptr, align 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000273 store i64 %tmp, i64* %out, align 4
274 ret i64* %ptr
275}
276
277define i32* @preidx32(i32* %src, i32* %out) {
278; CHECK: ldr w[[REG:[0-9]+]], [x0, #4]!
279; CHECK: str w[[REG]], [x1]
280; CHECK: ret
David Blaikie79e6c742015-02-27 19:29:02 +0000281 %ptr = getelementptr inbounds i32, i32* %src, i64 1
David Blaikiea79ac142015-02-27 21:17:42 +0000282 %tmp = load i32, i32* %ptr, align 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000283 store i32 %tmp, i32* %out, align 4
284 ret i32* %ptr
285}
286
287define i16* @preidx16zext32(i16* %src, i32* %out) {
288; CHECK: ldrh w[[REG:[0-9]+]], [x0, #2]!
289; CHECK: str w[[REG]], [x1]
290; CHECK: ret
David Blaikie79e6c742015-02-27 19:29:02 +0000291 %ptr = getelementptr inbounds i16, i16* %src, i64 1
David Blaikiea79ac142015-02-27 21:17:42 +0000292 %tmp = load i16, i16* %ptr, align 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000293 %ext = zext i16 %tmp to i32
294 store i32 %ext, i32* %out, align 4
295 ret i16* %ptr
296}
297
298define i16* @preidx16zext64(i16* %src, i64* %out) {
299; CHECK: ldrh w[[REG:[0-9]+]], [x0, #2]!
300; CHECK: str x[[REG]], [x1]
301; CHECK: ret
David Blaikie79e6c742015-02-27 19:29:02 +0000302 %ptr = getelementptr inbounds i16, i16* %src, i64 1
David Blaikiea79ac142015-02-27 21:17:42 +0000303 %tmp = load i16, i16* %ptr, align 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000304 %ext = zext i16 %tmp to i64
305 store i64 %ext, i64* %out, align 4
306 ret i16* %ptr
307}
308
309define i8* @preidx8zext32(i8* %src, i32* %out) {
310; CHECK: ldrb w[[REG:[0-9]+]], [x0, #1]!
311; CHECK: str w[[REG]], [x1]
312; CHECK: ret
David Blaikie79e6c742015-02-27 19:29:02 +0000313 %ptr = getelementptr inbounds i8, i8* %src, i64 1
David Blaikiea79ac142015-02-27 21:17:42 +0000314 %tmp = load i8, i8* %ptr, align 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000315 %ext = zext i8 %tmp to i32
316 store i32 %ext, i32* %out, align 4
317 ret i8* %ptr
318}
319
320define i8* @preidx8zext64(i8* %src, i64* %out) {
321; CHECK: ldrb w[[REG:[0-9]+]], [x0, #1]!
322; CHECK: str x[[REG]], [x1]
323; CHECK: ret
David Blaikie79e6c742015-02-27 19:29:02 +0000324 %ptr = getelementptr inbounds i8, i8* %src, i64 1
David Blaikiea79ac142015-02-27 21:17:42 +0000325 %tmp = load i8, i8* %ptr, align 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000326 %ext = zext i8 %tmp to i64
327 store i64 %ext, i64* %out, align 4
328 ret i8* %ptr
329}
330
331define i32* @preidx32sext64(i32* %src, i64* %out) {
332; CHECK: ldrsw x[[REG:[0-9]+]], [x0, #4]!
333; CHECK: str x[[REG]], [x1]
334; CHECK: ret
David Blaikie79e6c742015-02-27 19:29:02 +0000335 %ptr = getelementptr inbounds i32, i32* %src, i64 1
David Blaikiea79ac142015-02-27 21:17:42 +0000336 %tmp = load i32, i32* %ptr, align 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000337 %ext = sext i32 %tmp to i64
338 store i64 %ext, i64* %out, align 8
339 ret i32* %ptr
340}
341
342define i16* @preidx16sext32(i16* %src, i32* %out) {
343; CHECK: ldrsh w[[REG:[0-9]+]], [x0, #2]!
344; CHECK: str w[[REG]], [x1]
345; CHECK: ret
David Blaikie79e6c742015-02-27 19:29:02 +0000346 %ptr = getelementptr inbounds i16, i16* %src, i64 1
David Blaikiea79ac142015-02-27 21:17:42 +0000347 %tmp = load i16, i16* %ptr, align 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000348 %ext = sext i16 %tmp to i32
349 store i32 %ext, i32* %out, align 4
350 ret i16* %ptr
351}
352
353define i16* @preidx16sext64(i16* %src, i64* %out) {
354; CHECK: ldrsh x[[REG:[0-9]+]], [x0, #2]!
355; CHECK: str x[[REG]], [x1]
356; CHECK: ret
David Blaikie79e6c742015-02-27 19:29:02 +0000357 %ptr = getelementptr inbounds i16, i16* %src, i64 1
David Blaikiea79ac142015-02-27 21:17:42 +0000358 %tmp = load i16, i16* %ptr, align 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000359 %ext = sext i16 %tmp to i64
360 store i64 %ext, i64* %out, align 4
361 ret i16* %ptr
362}
363
364define i8* @preidx8sext32(i8* %src, i32* %out) {
365; CHECK: ldrsb w[[REG:[0-9]+]], [x0, #1]!
366; CHECK: str w[[REG]], [x1]
367; CHECK: ret
David Blaikie79e6c742015-02-27 19:29:02 +0000368 %ptr = getelementptr inbounds i8, i8* %src, i64 1
David Blaikiea79ac142015-02-27 21:17:42 +0000369 %tmp = load i8, i8* %ptr, align 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000370 %ext = sext i8 %tmp to i32
371 store i32 %ext, i32* %out, align 4
372 ret i8* %ptr
373}
374
375define i8* @preidx8sext64(i8* %src, i64* %out) {
376; CHECK: ldrsb x[[REG:[0-9]+]], [x0, #1]!
377; CHECK: str x[[REG]], [x1]
378; CHECK: ret
David Blaikie79e6c742015-02-27 19:29:02 +0000379 %ptr = getelementptr inbounds i8, i8* %src, i64 1
David Blaikiea79ac142015-02-27 21:17:42 +0000380 %tmp = load i8, i8* %ptr, align 4
Tim Northover3b0846e2014-05-24 12:50:23 +0000381 %ext = sext i8 %tmp to i64
382 store i64 %ext, i64* %out, align 4
383 ret i8* %ptr
384}
Quentin Colombetc64c1752014-08-11 21:39:53 +0000385
386; This test checks if illegal post-index is generated
387
388define i64* @postidx_clobber(i64* %addr) nounwind noinline ssp {
389; CHECK-LABEL: postidx_clobber:
390; CHECK-NOT: str x0, [x0], #8
391; ret
392 %paddr = bitcast i64* %addr to i64**
393 store i64* %addr, i64** %paddr
David Blaikie79e6c742015-02-27 19:29:02 +0000394 %newaddr = getelementptr i64, i64* %addr, i32 1
Quentin Colombetc64c1752014-08-11 21:39:53 +0000395 ret i64* %newaddr
396}