Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/vdup_lane_2.c

raw
1 /* Test vdup_lane intrinsics work correctly. */
2 /* { dg-do run } */
3 /* { dg-options "-O1 --save-temps" } */
4
5 #include <arm_neon.h>
6
7 #define force_simd(V1) asm volatile ("mov %d0, %1.d[0]" \
8 : "=w"(V1) \
9 : "w"(V1) \
10 : /* No clobbers */)
11
12 extern void abort (void);
13
14 mfloat8_t __attribute__ ((noinline))
15 wrap_vdupb_lane_mf8_0 (mfloat8x8_t dummy, mfloat8x8_t a)
16 {
17 mfloat8_t result = vdupb_lane_mf8 (a, 0);
18 force_simd (result);
19 return result;
20 }
21
22 mfloat8_t __attribute__ ((noinline))
23 wrap_vdupb_lane_mf8_1 (mfloat8x8_t a)
24 {
25 mfloat8_t result = vdupb_lane_mf8 (a, 1);
26 force_simd (result);
27 return result;
28 }
29
30 int __attribute__ ((noinline))
31 test_vdupb_lane_mf8 ()
32 {
33 mfloat8_t m;
34 uint8_t n = 11;
35 mfloat8x8_t a;
36 mfloat8_t b;
37 mfloat8_t c[8];
38
39 __builtin_memcpy(&m, &n, 1);
40 a = vdup_n_mf8 (m);
41 vst1_mf8 (c, a);
42
43 b = wrap_vdupb_lane_mf8_0 (a, a);
44 if (__builtin_memcmp (&c[0], &b, 1) != 0)
45 return 1;
46 b = wrap_vdupb_lane_mf8_1 (a);
47 if (__builtin_memcmp (&c[1], &b, 1) != 0)
48 return 1;
49
50 return 0;
51 }
52
53 float32_t __attribute__ ((noinline))
54 wrap_vdups_lane_f32_0 (float32x2_t dummy, float32x2_t a)
55 {
56 return vdups_lane_f32 (a, 0);
57 }
58
59 float32_t __attribute__ ((noinline))
60 wrap_vdups_lane_f32_1 (float32x2_t a)
61 {
62 return vdups_lane_f32 (a, 1);
63 }
64
65 int __attribute__ ((noinline))
66 test_vdups_lane_f32 ()
67 {
68 float32x2_t a;
69 float32_t b;
70 float32_t c[2] = { 0.0, 1.0 };
71
72 a = vld1_f32 (c);
73 b = wrap_vdups_lane_f32_0 (a, a);
74 if (c[0] != b)
75 return 1;
76 b = wrap_vdups_lane_f32_1 (a);
77 if (c[1] != b)
78 return 1;
79 return 0;
80 }
81
82 float64_t __attribute__ ((noinline))
83 wrap_vdupd_lane_f64_0 (float64x1_t dummy, float64x1_t a)
84 {
85 return vdupd_lane_f64 (a, 0);
86 }
87
88 int __attribute__ ((noinline))
89 test_vdupd_lane_f64 ()
90 {
91 float64x1_t a;
92 float64_t b;
93 float64_t c[1] = { 0.0 };
94 a = vld1_f64 (c);
95 b = wrap_vdupd_lane_f64_0 (a, a);
96 if (c[0] != b)
97 return 1;
98 return 0;
99 }
100
101 int8_t __attribute__ ((noinline))
102 wrap_vdupb_lane_s8_0 (int8x8_t dummy, int8x8_t a)
103 {
104 int8_t result = vdupb_lane_s8 (a, 0);
105 force_simd (result);
106 return result;
107 }
108
109 int8_t __attribute__ ((noinline))
110 wrap_vdupb_lane_s8_1 (int8x8_t a)
111 {
112 int8_t result = vdupb_lane_s8 (a, 1);
113 force_simd (result);
114 return result;
115 }
116
117 int __attribute__ ((noinline))
118 test_vdupb_lane_s8 ()
119 {
120 int8x8_t a;
121 int8_t b;
122 int8_t c[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
123
124 a = vld1_s8 (c);
125 b = wrap_vdupb_lane_s8_0 (a, a);
126 if (c[0] != b)
127 return 1;
128 b = wrap_vdupb_lane_s8_1 (a);
129 if (c[1] != b)
130 return 1;
131
132 return 0;
133 }
134
135 uint8_t __attribute__ ((noinline))
136 wrap_vdupb_lane_u8_0 (uint8x8_t dummy, uint8x8_t a)
137 {
138 uint8_t result = vdupb_lane_u8 (a, 0);
139 force_simd (result);
140 return result;
141 }
142
143 uint8_t __attribute__ ((noinline))
144 wrap_vdupb_lane_u8_1 (uint8x8_t a)
145 {
146 uint8_t result = vdupb_lane_u8 (a, 1);
147 force_simd (result);
148 return result;
149 }
150
151 int __attribute__ ((noinline))
152 test_vdupb_lane_u8 ()
153 {
154 uint8x8_t a;
155 uint8_t b;
156 uint8_t c[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
157
158 a = vld1_u8 (c);
159 b = wrap_vdupb_lane_u8_0 (a, a);
160 if (c[0] != b)
161 return 1;
162 b = wrap_vdupb_lane_u8_1 (a);
163 if (c[1] != b)
164 return 1;
165 return 0;
166 }
167
168 int16_t __attribute__ ((noinline))
169 wrap_vduph_lane_s16_0 (int16x4_t dummy, int16x4_t a)
170 {
171 int16_t result = vduph_lane_s16 (a, 0);
172 force_simd (result);
173 return result;
174 }
175
176 int16_t __attribute__ ((noinline))
177 wrap_vduph_lane_s16_1 (int16x4_t a)
178 {
179 int16_t result = vduph_lane_s16 (a, 1);
180 force_simd (result);
181 return result;
182 }
183
184 int __attribute__ ((noinline))
185 test_vduph_lane_s16 ()
186 {
187 int16x4_t a;
188 int16_t b;
189 int16_t c[4] = { 0, 1, 2, 3 };
190
191 a = vld1_s16 (c);
192 b = wrap_vduph_lane_s16_0 (a, a);
193 if (c[0] != b)
194 return 1;
195 b = wrap_vduph_lane_s16_1 (a);
196 if (c[1] != b)
197 return 1;
198 return 0;
199 }
200
201 uint16_t __attribute__ ((noinline))
202 wrap_vduph_lane_u16_0 (uint16x4_t dummy, uint16x4_t a)
203 {
204 uint16_t result = vduph_lane_u16 (a, 0);
205 force_simd (result);
206 return result;
207 }
208
209 uint16_t __attribute__ ((noinline))
210 wrap_vduph_lane_u16_1 (uint16x4_t a)
211 {
212 uint16_t result = vduph_lane_u16 (a, 1);
213 force_simd (result);
214 return result;
215 }
216
217 int __attribute__ ((noinline))
218 test_vduph_lane_u16 ()
219 {
220 uint16x4_t a;
221 uint16_t b;
222 uint16_t c[4] = { 0, 1, 2, 3 };
223
224 a = vld1_u16 (c);
225 b = wrap_vduph_lane_u16_0 (a, a);
226 if (c[0] != b)
227 return 1;
228 b = wrap_vduph_lane_u16_1 (a);
229 if (c[1] != b)
230 return 1;
231 return 0;
232 }
233
234 int32_t __attribute__ ((noinline))
235 wrap_vdups_lane_s32_0 (int32x2_t dummy, int32x2_t a)
236 {
237 int32_t result = vdups_lane_s32 (a, 0);
238 force_simd (result);
239 return result;
240 }
241
242 int32_t __attribute__ ((noinline))
243 wrap_vdups_lane_s32_1 (int32x2_t a)
244 {
245 int32_t result = vdups_lane_s32 (a, 1);
246 force_simd (result);
247 return result;
248 }
249
250 int __attribute__ ((noinline))
251 test_vdups_lane_s32 ()
252 {
253 int32x2_t a;
254 int32_t b;
255 int32_t c[2] = { 0, 1 };
256
257 a = vld1_s32 (c);
258 b = wrap_vdups_lane_s32_0 (vcreate_s32 (0), a);
259 if (c[0] != b)
260 return 1;
261 b = wrap_vdups_lane_s32_1 (a);
262 if (c[1] != b)
263 return 1;
264 return 0;
265 }
266
267 uint32_t __attribute__ ((noinline))
268 wrap_vdups_lane_u32_0 (uint32x2_t dummy, uint32x2_t a)
269 {
270 uint32_t result = vdups_lane_u32 (a, 0);
271 force_simd (result);
272 return result;
273 }
274
275 uint32_t __attribute__ ((noinline))
276 wrap_vdups_lane_u32_1 (uint32x2_t a)
277 {
278 uint32_t result = vdups_lane_u32 (a, 1);
279 force_simd (result);
280 return result;
281 }
282
283 int __attribute__ ((noinline))
284 test_vdups_lane_u32 ()
285 {
286 uint32x2_t a;
287 uint32_t b;
288 uint32_t c[2] = { 0, 1 };
289 a = vld1_u32 (c);
290 b = wrap_vdups_lane_u32_0 (a, a);
291 if (c[0] != b)
292 return 1;
293 b = wrap_vdups_lane_u32_1 (a);
294 if (c[1] != b)
295 return 1;
296 return 0;
297 }
298
299 uint64_t __attribute__ ((noinline))
300 wrap_vdupd_lane_u64_0 (uint64x1_t dummy, uint64x1_t a)
301 {
302 return vdupd_lane_u64 (a, 0);;
303 }
304
305 int __attribute__ ((noinline))
306 test_vdupd_lane_u64 ()
307 {
308 uint64x1_t a;
309 uint64_t b;
310 uint64_t c[1] = { 0 };
311
312 a = vld1_u64 (c);
313 b = wrap_vdupd_lane_u64_0 (a, a);
314 if (c[0] != b)
315 return 1;
316 return 0;
317 }
318
319 int64_t __attribute__ ((noinline))
320 wrap_vdupd_lane_s64_0 (int64x1_t dummy, int64x1_t a)
321 {
322 return vdupd_lane_s64 (a, 0);
323 }
324
325 int __attribute__ ((noinline))
326 test_vdupd_lane_s64 ()
327 {
328 int64x1_t a;
329 int64_t b;
330 int64_t c[1] = { 0 };
331
332 a = vld1_s64 (c);
333 b = wrap_vdupd_lane_s64_0 (a, a);
334 if (c[0] != b)
335 return 1;
336 return 0;
337 }
338
339 int
340 main ()
341 {
342 if (test_vdupb_lane_mf8 ())
343 abort ();
344 if (test_vdups_lane_f32 ())
345 abort ();
346 if (test_vdupd_lane_f64 ())
347 abort ();
348 if (test_vdupb_lane_s8 ())
349 abort ();
350 if (test_vdupb_lane_u8 ())
351 abort ();
352 if (test_vduph_lane_s16 ())
353 abort ();
354 if (test_vduph_lane_u16 ())
355 abort ();
356 if (test_vdups_lane_s32 ())
357 abort ();
358 if (test_vdups_lane_u32 ())
359 abort ();
360 if (test_vdupd_lane_s64 ())
361 abort ();
362 if (test_vdupd_lane_u64 ())
363 abort ();
364 return 0;
365 }
366
367 /* Asm check for vdupb_lane_s8, vdupb_lane_u8, and vdupb_lane_mf8. */
368 /* { dg-final { scan-assembler-not "dup\\tb\[0-9\]+, v\[0-9\]+\.b\\\[0\\\]" } } */
369 /* { dg-final { scan-assembler-times "dup\\tb\[0-9\]+, v\[0-9\]+\.b\\\[1\\\]" 3 } } */
370
371 /* Asm check for vduph_lane_h16, vduph_lane_h16. */
372 /* { dg-final { scan-assembler-not "dup\\th\[0-9\]+, v\[0-9\]+\.h\\\[0\\\]" } } */
373 /* { dg-final { scan-assembler-times "dup\\th\[0-9\]+, v\[0-9\]+\.h\\\[1\\\]" 2 } } */
374
375 /* Asm check for vdups_lane_f32, vdups_lane_s32, vdups_lane_u32. */
376 /* Can't generate "dup s<n>, v<m>[0]" for vdups_lane_s32 and vdups_lane_u32. */
377 /* { dg-final { scan-assembler-times {fmov\ts0, s1} 1 } } */
378 /* { dg-final { scan-assembler-times "dup\\ts\[0-9\]+, v\[0-9\]+\.s\\\[1\\\]" 3 } } */
379
380 /* Asm check for vdupd_lane_f64, vdupd_lane_s64, vdupd_lane_u64. */
381 /* Attempts to make the compiler generate vdupd are not practical. */
382 /* { dg-final { scan-assembler-not "dup\\td\[0-9\]+, v\[0-9\]+\.d\\\[0\\\]" } } */
383