Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/vdup_lane_1.c

raw
1 /* Test vdup_lane intrinsics work correctly. */
2 /* { dg-do run } */
3 /* { dg-options "--save-temps -O1" } */
4
5 #include <arm_neon.h>
6
7 extern void abort (void);
8
9 mfloat8x8_t __attribute__ ((noinline))
10 wrap_vdup_lane_mf8_0 (mfloat8x8_t a)
11 {
12 return vdup_lane_mf8 (a, 0);
13 }
14
15 mfloat8x8_t __attribute__ ((noinline))
16 wrap_vdup_lane_mf8_1 (mfloat8x8_t a)
17 {
18 return vdup_lane_mf8 (a, 1);
19 }
20
21 int __attribute__ ((noinline))
22 test_vdup_lane_mf8 ()
23 {
24 mfloat8_t m;
25 uint8_t n = 11;
26 mfloat8x8_t a;
27 mfloat8x8_t b;
28 int i;
29 /* Only two first cases are interesting. */
30 mfloat8_t c[8];
31 mfloat8_t d[8];
32
33 __builtin_memcpy(&m, &n, 1);
34 b = vdup_n_mf8 (m);
35 vst1_mf8 (d, b);
36
37 a = vld1_mf8 (c);
38 b = wrap_vdup_lane_mf8_0 (a);
39 vst1_mf8 (d, b);
40 for (i = 0; i < 8; i++)
41 if (__builtin_memcmp (&c[0], &d[i], 1) != 0)
42 return 1;
43
44 b = wrap_vdup_lane_mf8_1 (a);
45 vst1_mf8 (d, b);
46 for (i = 0; i < 8; i++)
47 if (__builtin_memcmp (&c[1], &d[i], 1) != 0)
48 return 1;
49 return 0;
50 }
51
52 mfloat8x16_t __attribute__ ((noinline))
53 wrap_vdupq_lane_mf8_0 (mfloat8x8_t a)
54 {
55 return vdupq_lane_mf8 (a, 0);
56 }
57
58 mfloat8x16_t __attribute__ ((noinline))
59 wrap_vdupq_lane_mf8_1 (mfloat8x8_t a)
60 {
61 return vdupq_lane_mf8 (a, 1);
62 }
63
64 int __attribute__ ((noinline))
65 test_vdupq_lane_mf8 ()
66 {
67 mfloat8_t m;
68 uint8_t n = 11;
69 mfloat8x8_t a;
70 mfloat8x16_t b;
71 int i;
72 /* Only two first cases are interesting. */
73 mfloat8_t c[8];
74 mfloat8_t d[16];
75
76 __builtin_memcpy(&m, &n, 1);
77 b = vdupq_n_mf8 (m);
78 vst1q_mf8 (d, b);
79
80 a = vld1_mf8 (c);
81 b = wrap_vdupq_lane_mf8_0 (a);
82 vst1q_mf8 (d, b);
83 for (i = 0; i < 16; i++)
84 if (__builtin_memcmp (&c[0], &d[i], 1) != 0)
85 return 1;
86
87 b = wrap_vdupq_lane_mf8_1 (a);
88 vst1q_mf8 (d, b);
89 for (i = 0; i < 16; i++)
90 if (__builtin_memcmp (&c[1], &d[i], 1) != 0)
91 return 1;
92 return 0;
93 }
94
95 float32x2_t __attribute__ ((noinline))
96 wrap_vdup_lane_f32_0 (float32x2_t a)
97 {
98 return vdup_lane_f32 (a, 0);
99 }
100
101 float32x2_t __attribute__ ((noinline))
102 wrap_vdup_lane_f32_1 (float32x2_t a)
103 {
104 return vdup_lane_f32 (a, 1);
105 }
106
107 int __attribute__ ((noinline))
108 test_vdup_lane_f32 ()
109 {
110 float32x2_t a;
111 float32x2_t b;
112 int i;
113 float32_t c[2] = { 0.0 , 3.14 };
114 float32_t d[2];
115
116 a = vld1_f32 (c);
117 b = wrap_vdup_lane_f32_0 (a);
118 vst1_f32 (d, b);
119 for (i = 0; i < 2; i++)
120 if (c[0] != d[i])
121 return 1;
122
123 b = wrap_vdup_lane_f32_1 (a);
124 vst1_f32 (d, b);
125 for (i = 0; i < 2; i++)
126 if (c[1] != d[i])
127 return 1;
128 return 0;
129 }
130
131 float32x4_t __attribute__ ((noinline))
132 wrap_vdupq_lane_f32_0 (float32x2_t a)
133 {
134 return vdupq_lane_f32 (a, 0);
135 }
136
137 float32x4_t __attribute__ ((noinline))
138 wrap_vdupq_lane_f32_1 (float32x2_t a)
139 {
140 return vdupq_lane_f32 (a, 1);
141 }
142
143 int __attribute__ ((noinline))
144 test_vdupq_lane_f32 ()
145 {
146 float32x2_t a;
147 float32x4_t b;
148 int i;
149 float32_t c[2] = { 0.0 , 3.14 };
150 float32_t d[4];
151
152 a = vld1_f32 (c);
153 b = wrap_vdupq_lane_f32_0 (a);
154 vst1q_f32 (d, b);
155 for (i = 0; i < 4; i++)
156 if (c[0] != d[i])
157 return 1;
158
159 b = wrap_vdupq_lane_f32_1 (a);
160 vst1q_f32 (d, b);
161 for (i = 0; i < 4; i++)
162 if (c[1] != d[i])
163 return 1;
164 return 0;
165 }
166
167 int8x8_t __attribute__ ((noinline))
168 wrap_vdup_lane_s8_0 (int8x8_t a)
169 {
170 return vdup_lane_s8 (a, 0);
171 }
172
173 int8x8_t __attribute__ ((noinline))
174 wrap_vdup_lane_s8_1 (int8x8_t a)
175 {
176 return vdup_lane_s8 (a, 1);
177 }
178
179 int __attribute__ ((noinline))
180 test_vdup_lane_s8 ()
181 {
182 int8x8_t a;
183 int8x8_t b;
184 int i;
185 /* Only two first cases are interesting. */
186 int8_t c[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
187 int8_t d[8];
188
189 a = vld1_s8 (c);
190 b = wrap_vdup_lane_s8_0 (a);
191 vst1_s8 (d, b);
192 for (i = 0; i < 8; i++)
193 if (c[0] != d[i])
194 return 1;
195
196 b = wrap_vdup_lane_s8_1 (a);
197 vst1_s8 (d, b);
198 for (i = 0; i < 8; i++)
199 if (c[1] != d[i])
200 return 1;
201 return 0;
202 }
203
204 int8x16_t __attribute__ ((noinline))
205 wrap_vdupq_lane_s8_0 (int8x8_t a)
206 {
207 return vdupq_lane_s8 (a, 0);
208 }
209
210 int8x16_t __attribute__ ((noinline))
211 wrap_vdupq_lane_s8_1 (int8x8_t a)
212 {
213 return vdupq_lane_s8 (a, 1);
214 }
215
216 int __attribute__ ((noinline))
217 test_vdupq_lane_s8 ()
218 {
219 int8x8_t a;
220 int8x16_t b;
221 int i;
222 /* Only two first cases are interesting. */
223 int8_t c[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
224 int8_t d[16];
225
226 a = vld1_s8 (c);
227 b = wrap_vdupq_lane_s8_0 (a);
228 vst1q_s8 (d, b);
229 for (i = 0; i < 16; i++)
230 if (c[0] != d[i])
231 return 1;
232
233 b = wrap_vdupq_lane_s8_1 (a);
234 vst1q_s8 (d, b);
235 for (i = 0; i < 16; i++)
236 if (c[1] != d[i])
237 return 1;
238 return 0;
239 }
240
241 int16x4_t __attribute__ ((noinline))
242 wrap_vdup_lane_s16_0 (int16x4_t a)
243 {
244 return vdup_lane_s16 (a, 0);
245 }
246
247 int16x4_t __attribute__ ((noinline))
248 wrap_vdup_lane_s16_1 (int16x4_t a)
249 {
250 return vdup_lane_s16 (a, 1);
251 }
252
253 int __attribute__ ((noinline))
254 test_vdup_lane_s16 ()
255 {
256 int16x4_t a;
257 int16x4_t b;
258 int i;
259 /* Only two first cases are interesting. */
260 int16_t c[4] = { 0, 1, 2, 3 };
261 int16_t d[4];
262
263 a = vld1_s16 (c);
264 b = wrap_vdup_lane_s16_0 (a);
265 vst1_s16 (d, b);
266 for (i = 0; i < 4; i++)
267 if (c[0] != d[i])
268 return 1;
269
270 b = wrap_vdup_lane_s16_1 (a);
271 vst1_s16 (d, b);
272 for (i = 0; i < 4; i++)
273 if (c[1] != d[i])
274 return 1;
275 return 0;
276 }
277
278 int16x8_t __attribute__ ((noinline))
279 wrap_vdupq_lane_s16_0 (int16x4_t a)
280 {
281 return vdupq_lane_s16 (a, 0);
282 }
283
284 int16x8_t __attribute__ ((noinline))
285 wrap_vdupq_lane_s16_1 (int16x4_t a)
286 {
287 return vdupq_lane_s16 (a, 1);
288 }
289
290 int __attribute__ ((noinline))
291 test_vdupq_lane_s16 ()
292 {
293 int16x4_t a;
294 int16x8_t b;
295 int i;
296 /* Only two first cases are interesting. */
297 int16_t c[4] = { 0, 1, 2, 3 };
298 int16_t d[8];
299
300 a = vld1_s16 (c);
301 b = wrap_vdupq_lane_s16_0 (a);
302 vst1q_s16 (d, b);
303 for (i = 0; i < 8; i++)
304 if (c[0] != d[i])
305 return 1;
306
307 b = wrap_vdupq_lane_s16_1 (a);
308 vst1q_s16 (d, b);
309 for (i = 0; i < 8; i++)
310 if (c[1] != d[i])
311 return 1;
312 return 0;
313 }
314
315 int32x2_t __attribute__ ((noinline))
316 wrap_vdup_lane_s32_0 (int32x2_t a)
317 {
318 return vdup_lane_s32 (a, 0);
319 }
320
321 int32x2_t __attribute__ ((noinline))
322 wrap_vdup_lane_s32_1 (int32x2_t a)
323 {
324 return vdup_lane_s32 (a, 1);
325 }
326
327 int __attribute__ ((noinline))
328 test_vdup_lane_s32 ()
329 {
330 int32x2_t a;
331 int32x2_t b;
332 int i;
333 int32_t c[2] = { 0, 1 };
334 int32_t d[2];
335
336 a = vld1_s32 (c);
337 b = wrap_vdup_lane_s32_0 (a);
338 vst1_s32 (d, b);
339 for (i = 0; i < 2; i++)
340 if (c[0] != d[i])
341 return 1;
342
343 b = wrap_vdup_lane_s32_1 (a);
344 vst1_s32 (d, b);
345 for (i = 0; i < 2; i++)
346 if (c[1] != d[i])
347 return 1;
348 return 0;
349 }
350
351 int32x4_t __attribute__ ((noinline))
352 wrap_vdupq_lane_s32_0 (int32x2_t a)
353 {
354 return vdupq_lane_s32 (a, 0);
355 }
356
357 int32x4_t __attribute__ ((noinline))
358 wrap_vdupq_lane_s32_1 (int32x2_t a)
359 {
360 return vdupq_lane_s32 (a, 1);
361 }
362
363 int __attribute__ ((noinline))
364 test_vdupq_lane_s32 ()
365 {
366 int32x2_t a;
367 int32x4_t b;
368 int i;
369 int32_t c[2] = { 0, 1 };
370 int32_t d[4];
371
372 a = vld1_s32 (c);
373 b = wrap_vdupq_lane_s32_0 (a);
374 vst1q_s32 (d, b);
375 for (i = 0; i < 4; i++)
376 if (c[0] != d[i])
377 return 1;
378
379 b = wrap_vdupq_lane_s32_1 (a);
380 vst1q_s32 (d, b);
381 for (i = 0; i < 4; i++)
382 if (c[1] != d[i])
383 return 1;
384 return 0;
385 }
386
387 int64x1_t __attribute__ ((noinline))
388 wrap_vdup_lane_s64_0 (int64x1_t a)
389 {
390 return vdup_lane_s64 (a, 0);
391 }
392
393 int __attribute__ ((noinline))
394 test_vdup_lane_s64 ()
395 {
396 int64x1_t a;
397 int64x1_t b;
398 int64_t c[1];
399 int64_t d[1];
400
401 c[0] = 0;
402 a = vld1_s64 (c);
403 b = wrap_vdup_lane_s64_0 (a);
404 vst1_s64 (d, b);
405 if (c[0] != d[0])
406 return 1;
407
408 return 0;
409 }
410
411 int64x2_t __attribute__ ((noinline))
412 wrap_vdupq_lane_s64_0 (int64x1_t a)
413 {
414 return vdupq_lane_s64 (a, 0);
415 }
416
417 int __attribute__ ((noinline))
418 test_vdupq_lane_s64 ()
419 {
420 int64x1_t a;
421 int64x2_t b;
422 int i;
423 int64_t c[1];
424 int64_t d[2];
425
426 c[0] = 0;
427 a = vld1_s64 (c);
428 b = wrap_vdupq_lane_s64_0 (a);
429 vst1q_s64 (d, b);
430 for (i = 0; i < 2; i++)
431 if (c[0] != d[i])
432 return 1;
433 return 0;
434 }
435
436 int
437 main ()
438 {
439 if (test_vdup_lane_mf8 ())
440 abort ();
441 if (test_vdupq_lane_mf8 ())
442 abort ();
443 if (test_vdup_lane_f32 ())
444 abort ();
445 if (test_vdup_lane_s8 ())
446 abort ();
447 if (test_vdup_lane_s16 ())
448 abort ();
449 if (test_vdup_lane_s32 ())
450 abort ();
451 if (test_vdup_lane_s64 ())
452 abort ();
453 if (test_vdupq_lane_f32 ())
454 abort ();
455 if (test_vdupq_lane_s8 ())
456 abort ();
457 if (test_vdupq_lane_s16 ())
458 abort ();
459 if (test_vdupq_lane_s32 ())
460 abort ();
461 if (test_vdupq_lane_s64 ())
462 abort ();
463
464 return 0;
465 }
466
467 /* Asm check for test_vdup_lane_s8. */
468 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.8b, v\[0-9\]+\.b\\\[0\\\]" 2 } } */
469 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.8b, v\[0-9\]+\.b\\\[1\\\]" 2 } } */
470
471 /* Asm check for test_vdupq_lane_s8. */
472 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.16b, v\[0-9\]+\.b\\\[0\\\]" 2 } } */
473 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.16b, v\[0-9\]+\.b\\\[1\\\]" 2 } } */
474
475 /* Asm check for test_vdup_lane_s16. */
476 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.4h, v\[0-9\]+\.h\\\[0\\\]" 1 } } */
477 /* Asm check for test_vdup_lane_s16. */
478 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.4h, v\[0-9\]+\.h\\\[1\\\]" 1 } } */
479
480 /* Asm check for test_vdupq_lane_s16. */
481 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.8h, v\[0-9\]+\.h\\\[0\\\]" 1 } } */
482 /* Asm check for test_vdupq_lane_s16. */
483 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.8h, v\[0-9\]+\.h\\\[1\\\]" 1 } } */
484
485 /* Asm check for test_vdup_lane_f32 and test_vdup_lane_s32. */
486 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.2s, v\[0-9\]+\.s\\\[0\\\]" 2 } } */
487 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.2s, v\[0-9\]+\.s\\\[1\\\]" 2 } } */
488
489 /* Asm check for test_vdupq_lane_f32 and test_vdupq_lane_s32. */
490 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.4s, v\[0-9\]+\.s\\\[0\\\]" 2 } } */
491 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.4s, v\[0-9\]+\.s\\\[1\\\]" 2 } } */
492