Add execution + assembler tests of AArch64 TRN Intrinsics.
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / vdup_n_1.c
bloba79910d68d744314205f9ecab67ec07560681725
1 /* Test vdup_lane intrinsics work correctly. */
2 /* { dg-do run } */
3 /* { dg-options "-O1 --save-temps" } */
5 #include <arm_neon.h>
7 extern void abort (void);
9 float32x2_t __attribute__ ((noinline))
10 wrap_vdup_n_f32 (float32_t a)
12 return vdup_n_f32 (a);
15 int __attribute__ ((noinline))
16 test_vdup_n_f32 ()
18 float32_t a = 1.0;
19 float32x2_t b;
20 float32_t c[2];
21 int i;
23 b = wrap_vdup_n_f32 (a);
24 vst1_f32 (c, b);
25 for (i = 0; i < 2; i++)
26 if (a != c[i])
27 return 1;
28 return 0;
31 float32x4_t __attribute__ ((noinline))
32 wrap_vdupq_n_f32 (float32_t a)
34 return vdupq_n_f32 (a);
37 int __attribute__ ((noinline))
38 test_vdupq_n_f32 ()
40 float32_t a = 1.0;
41 float32x4_t b;
42 float32_t c[4];
43 int i;
45 b = wrap_vdupq_n_f32 (a);
46 vst1q_f32 (c, b);
47 for (i = 0; i < 4; i++)
48 if (a != c[i])
49 return 1;
50 return 0;
53 float64x1_t __attribute__ ((noinline))
54 wrap_vdup_n_f64 (float64_t a)
56 return vdup_n_f64 (a);
59 int __attribute__ ((noinline))
60 test_vdup_n_f64 ()
62 float64_t a = 1.0;
63 float64x1_t b;
64 float64_t c[1];
65 int i;
67 b = wrap_vdup_n_f64 (a);
68 vst1_f64 (c, b);
69 for (i = 0; i < 1; i++)
70 if (a != c[i])
71 return 1;
72 return 0;
75 float64x2_t __attribute__ ((noinline))
76 wrap_vdupq_n_f64 (float64_t a)
78 return vdupq_n_f64 (a);
81 int __attribute__ ((noinline))
82 test_vdupq_n_f64 ()
84 float64_t a = 1.0;
85 float64x2_t b;
86 float64_t c[2];
87 int i;
89 b = wrap_vdupq_n_f64 (a);
90 vst1q_f64 (c, b);
91 for (i = 0; i < 2; i++)
92 if (a != c[i])
93 return 1;
94 return 0;
97 poly8x8_t __attribute__ ((noinline))
98 wrap_vdup_n_p8 (poly8_t a)
100 return vdup_n_p8 (a);
103 int __attribute__ ((noinline))
104 test_vdup_n_p8 ()
106 poly8_t a = 1;
107 poly8x8_t b;
108 poly8_t c[8];
109 int i;
111 b = wrap_vdup_n_p8 (a);
112 vst1_p8 (c, b);
113 for (i = 0; i < 8; i++)
114 if (a != c[i])
115 return 1;
116 return 0;
119 poly8x16_t __attribute__ ((noinline))
120 wrap_vdupq_n_p8 (poly8_t a)
122 return vdupq_n_p8 (a);
125 int __attribute__ ((noinline))
126 test_vdupq_n_p8 ()
128 poly8_t a = 1;
129 poly8x16_t b;
130 poly8_t c[16];
131 int i;
133 b = wrap_vdupq_n_p8 (a);
134 vst1q_p8 (c, b);
135 for (i = 0; i < 16; i++)
136 if (a != c[i])
137 return 1;
138 return 0;
141 int8x8_t __attribute__ ((noinline))
142 wrap_vdup_n_s8 (int8_t a)
144 return vdup_n_s8 (a);
147 int __attribute__ ((noinline))
148 test_vdup_n_s8 ()
150 int8_t a = 1;
151 int8x8_t b;
152 int8_t c[8];
153 int i;
155 b = wrap_vdup_n_s8 (a);
156 vst1_s8 (c, b);
157 for (i = 0; i < 8; i++)
158 if (a != c[i])
159 return 1;
160 return 0;
163 int8x16_t __attribute__ ((noinline))
164 wrap_vdupq_n_s8 (int8_t a)
166 return vdupq_n_s8 (a);
169 int __attribute__ ((noinline))
170 test_vdupq_n_s8 ()
172 int8_t a = 1;
173 int8x16_t b;
174 int8_t c[16];
175 int i;
177 b = wrap_vdupq_n_s8 (a);
178 vst1q_s8 (c, b);
179 for (i = 0; i < 16; i++)
180 if (a != c[i])
181 return 1;
182 return 0;
185 uint8x8_t __attribute__ ((noinline))
186 wrap_vdup_n_u8 (uint8_t a)
188 return vdup_n_u8 (a);
191 int __attribute__ ((noinline))
192 test_vdup_n_u8 ()
194 uint8_t a = 1;
195 uint8x8_t b;
196 uint8_t c[8];
197 int i;
199 b = wrap_vdup_n_u8 (a);
200 vst1_u8 (c, b);
201 for (i = 0; i < 8; i++)
202 if (a != c[i])
203 return 1;
204 return 0;
207 uint8x16_t __attribute__ ((noinline))
208 wrap_vdupq_n_u8 (uint8_t a)
210 return vdupq_n_u8 (a);
213 int __attribute__ ((noinline))
214 test_vdupq_n_u8 ()
216 uint8_t a = 1;
217 uint8x16_t b;
218 uint8_t c[16];
219 int i;
221 b = wrap_vdupq_n_u8 (a);
222 vst1q_u8 (c, b);
223 for (i = 0; i < 16; i++)
224 if (a != c[i])
225 return 1;
226 return 0;
229 poly16x4_t __attribute__ ((noinline))
230 wrap_vdup_n_p16 (poly16_t a)
232 return vdup_n_p16 (a);
235 int __attribute__ ((noinline))
236 test_vdup_n_p16 ()
238 poly16_t a = 1;
239 poly16x4_t b;
240 poly16_t c[4];
241 int i;
243 b = wrap_vdup_n_p16 (a);
244 vst1_p16 (c, b);
245 for (i = 0; i < 4; i++)
246 if (a != c[i])
247 return 1;
248 return 0;
251 poly16x8_t __attribute__ ((noinline))
252 wrap_vdupq_n_p16 (poly16_t a)
254 return vdupq_n_p16 (a);
257 int __attribute__ ((noinline))
258 test_vdupq_n_p16 ()
260 poly16_t a = 1;
261 poly16x8_t b;
262 poly16_t c[8];
263 int i;
265 b = wrap_vdupq_n_p16 (a);
266 vst1q_p16 (c, b);
267 for (i = 0; i < 8; i++)
268 if (a != c[i])
269 return 1;
270 return 0;
273 int16x4_t __attribute__ ((noinline))
274 wrap_vdup_n_s16 (int16_t a)
276 return vdup_n_s16 (a);
279 int __attribute__ ((noinline))
280 test_vdup_n_s16 ()
282 int16_t a = 1;
283 int16x4_t b;
284 int16_t c[4];
285 int i;
287 b = wrap_vdup_n_s16 (a);
288 vst1_s16 (c, b);
289 for (i = 0; i < 4; i++)
290 if (a != c[i])
291 return 1;
292 return 0;
295 int16x8_t __attribute__ ((noinline))
296 wrap_vdupq_n_s16 (int16_t a)
298 return vdupq_n_s16 (a);
301 int __attribute__ ((noinline))
302 test_vdupq_n_s16 ()
304 int16_t a = 1;
305 int16x8_t b;
306 int16_t c[8];
307 int i;
309 b = wrap_vdupq_n_s16 (a);
310 vst1q_s16 (c, b);
311 for (i = 0; i < 8; i++)
312 if (a != c[i])
313 return 1;
314 return 0;
317 uint16x4_t __attribute__ ((noinline))
318 wrap_vdup_n_u16 (uint16_t a)
320 return vdup_n_u16 (a);
323 int __attribute__ ((noinline))
324 test_vdup_n_u16 ()
326 uint16_t a = 1;
327 uint16x4_t b;
328 uint16_t c[4];
329 int i;
331 b = wrap_vdup_n_u16 (a);
332 vst1_u16 (c, b);
333 for (i = 0; i < 4; i++)
334 if (a != c[i])
335 return 1;
336 return 0;
339 uint16x8_t __attribute__ ((noinline))
340 wrap_vdupq_n_u16 (uint16_t a)
342 return vdupq_n_u16 (a);
345 int __attribute__ ((noinline))
346 test_vdupq_n_u16 ()
348 uint16_t a = 1;
349 uint16x8_t b;
350 uint16_t c[8];
351 int i;
353 b = wrap_vdupq_n_u16 (a);
354 vst1q_u16 (c, b);
355 for (i = 0; i < 8; i++)
356 if (a != c[i])
357 return 1;
358 return 0;
361 int32x2_t __attribute__ ((noinline))
362 wrap_vdup_n_s32 (int32_t a)
364 return vdup_n_s32 (a);
367 int __attribute__ ((noinline))
368 test_vdup_n_s32 ()
370 int32_t a = 1;
371 int32x2_t b;
372 int32_t c[2];
373 int i;
375 b = wrap_vdup_n_s32 (a);
376 vst1_s32 (c, b);
377 for (i = 0; i < 2; i++)
378 if (a != c[i])
379 return 1;
380 return 0;
383 int32x4_t __attribute__ ((noinline))
384 wrap_vdupq_n_s32 (int32_t a)
386 return vdupq_n_s32 (a);
389 int __attribute__ ((noinline))
390 test_vdupq_n_s32 ()
392 int32_t a = 1;
393 int32x4_t b;
394 int32_t c[4];
395 int i;
397 b = wrap_vdupq_n_s32 (a);
398 vst1q_s32 (c, b);
399 for (i = 0; i < 4; i++)
400 if (a != c[i])
401 return 1;
402 return 0;
405 uint32x2_t __attribute__ ((noinline))
406 wrap_vdup_n_u32 (uint32_t a)
408 return vdup_n_u32 (a);
411 int __attribute__ ((noinline))
412 test_vdup_n_u32 ()
414 uint32_t a = 1;
415 uint32x2_t b;
416 uint32_t c[2];
417 int i;
419 b = wrap_vdup_n_u32 (a);
420 vst1_u32 (c, b);
421 for (i = 0; i < 2; i++)
422 if (a != c[i])
423 return 1;
424 return 0;
427 uint32x4_t __attribute__ ((noinline))
428 wrap_vdupq_n_u32 (uint32_t a)
430 return vdupq_n_u32 (a);
433 int __attribute__ ((noinline))
434 test_vdupq_n_u32 ()
436 uint32_t a = 1;
437 uint32x4_t b;
438 uint32_t c[4];
439 int i;
441 b = wrap_vdupq_n_u32 (a);
442 vst1q_u32 (c, b);
443 for (i = 0; i < 4; i++)
444 if (a != c[i])
445 return 1;
446 return 0;
449 int64x1_t __attribute__ ((noinline))
450 wrap_vdup_n_s64 (int64_t a)
452 return vdup_n_s64 (a);
455 int __attribute__ ((noinline))
456 test_vdup_n_s64 ()
458 int64_t a = 1;
459 int64x1_t b;
460 int64_t c[1];
461 int i;
463 b = wrap_vdup_n_s64 (a);
464 vst1_s64 (c, b);
465 for (i = 0; i < 1; i++)
466 if (a != c[i])
467 return 1;
468 return 0;
471 int64x2_t __attribute__ ((noinline))
472 wrap_vdupq_n_s64 (int64_t a)
474 return vdupq_n_s64 (a);
477 int __attribute__ ((noinline))
478 test_vdupq_n_s64 ()
480 int64_t a = 1;
481 int64x2_t b;
482 int64_t c[2];
483 int i;
485 b = wrap_vdupq_n_s64 (a);
486 vst1q_s64 (c, b);
487 for (i = 0; i < 2; i++)
488 if (a != c[i])
489 return 1;
490 return 0;
493 uint64x1_t __attribute__ ((noinline))
494 wrap_vdup_n_u64 (uint64_t a)
496 return vdup_n_u64 (a);
499 int __attribute__ ((noinline))
500 test_vdup_n_u64 ()
502 uint64_t a = 1;
503 uint64x1_t b;
504 uint64_t c[1];
505 int i;
507 b = wrap_vdup_n_u64 (a);
508 vst1_u64 (c, b);
509 for (i = 0; i < 1; i++)
510 if (a != c[i])
511 return 1;
512 return 0;
515 uint64x2_t __attribute__ ((noinline))
516 wrap_vdupq_n_u64 (uint64_t a)
518 return vdupq_n_u64 (a);
521 int __attribute__ ((noinline))
522 test_vdupq_n_u64 ()
524 uint64_t a = 1;
525 uint64x2_t b;
526 uint64_t c[2];
527 int i;
529 b = wrap_vdupq_n_u64 (a);
530 vst1q_u64 (c, b);
531 for (i = 0; i < 2; i++)
532 if (a != c[i])
533 return 1;
534 return 0;
538 main ()
540 if (test_vdup_n_f32 ())
541 abort ();
542 if (test_vdup_n_f64 ())
543 abort ();
544 if (test_vdup_n_p8 ())
545 abort ();
546 if (test_vdup_n_u8 ())
547 abort ();
548 if (test_vdup_n_s8 ())
549 abort ();
550 if (test_vdup_n_p16 ())
551 abort ();
552 if (test_vdup_n_s16 ())
553 abort ();
554 if (test_vdup_n_u16 ())
555 abort ();
556 if (test_vdup_n_s32 ())
557 abort ();
558 if (test_vdup_n_u32 ())
559 abort ();
560 if (test_vdup_n_s64 ())
561 abort ();
562 if (test_vdup_n_u64 ())
563 abort ();
564 if (test_vdupq_n_f32 ())
565 abort ();
566 if (test_vdupq_n_f64 ())
567 abort ();
568 if (test_vdupq_n_p8 ())
569 abort ();
570 if (test_vdupq_n_u8 ())
571 abort ();
572 if (test_vdupq_n_s8 ())
573 abort ();
574 if (test_vdupq_n_p16 ())
575 abort ();
576 if (test_vdupq_n_s16 ())
577 abort ();
578 if (test_vdupq_n_u16 ())
579 abort ();
580 if (test_vdupq_n_s32 ())
581 abort ();
582 if (test_vdupq_n_u32 ())
583 abort ();
584 if (test_vdupq_n_s64 ())
585 abort ();
586 if (test_vdupq_n_u64 ())
587 abort ();
588 return 0;
591 /* No asm checks for vdup_n_f32, vdupq_n_f32, vdup_n_f64 and vdupq_n_f64.
592 Cannot force floating point value in general purpose regester. */
594 /* Asm check for test_vdup_n_p8, test_vdup_n_s8, test_vdup_n_u8. */
595 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.8b, w\[0-9\]+" 3 } } */
597 /* Asm check for test_vdupq_n_p8, test_vdupq_n_s8, test_vdupq_n_u8. */
598 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.16b, w\[0-9\]+" 3 } } */
600 /* Asm check for test_vdup_n_p16, test_vdup_n_s16, test_vdup_n_u16. */
601 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.4h, w\[0-9\]+" 3 } } */
603 /* Asm check for test_vdupq_n_p16, test_vdupq_n_s16, test_vdupq_n_u16. */
604 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.8h, w\[0-9\]+" 3 } } */
606 /* Asm check for test_vdup_n_s32, test_vdup_n_u32. */
607 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.2s, w\[0-9\]+" 2 } } */
609 /* Asm check for test_vdupq_n_s32, test_vdupq_n_u32. */
610 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.4s, w\[0-9\]+" 2 } } */
612 /* Asm check for test_vdup_n_s64, test_vdup_n_u64 are left out.
613 Attempts to make the compiler generate "dup\\td\[0-9\]+, x\[0-9\]+"
614 are not practical. */
616 /* Asm check for test_vdupq_n_s64, test_vdupq_n_u64. */
617 /* { dg-final { scan-assembler-times "dup\\tv\[0-9\]+\.2d, x\[0-9\]+" 2 } } */
619 /* { dg-final { cleanup-saved-temps } } */