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 extern void abort (void);
8
9 float32x2_t __attribute__ ((noinline))
wrap_vdup_n_f32(float32_t a)10 wrap_vdup_n_f32 (float32_t a)
11 {
12 return vdup_n_f32 (a);
13 }
14
15 int __attribute__ ((noinline))
test_vdup_n_f32()16 test_vdup_n_f32 ()
17 {
18 float32_t a = 1.0;
19 float32x2_t b;
20 float32_t c[2];
21 int i;
22
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;
29 }
30
31 float32x4_t __attribute__ ((noinline))
wrap_vdupq_n_f32(float32_t a)32 wrap_vdupq_n_f32 (float32_t a)
33 {
34 return vdupq_n_f32 (a);
35 }
36
37 int __attribute__ ((noinline))
test_vdupq_n_f32()38 test_vdupq_n_f32 ()
39 {
40 float32_t a = 1.0;
41 float32x4_t b;
42 float32_t c[4];
43 int i;
44
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;
51 }
52
53 float64x1_t __attribute__ ((noinline))
wrap_vdup_n_f64(float64_t a)54 wrap_vdup_n_f64 (float64_t a)
55 {
56 return vdup_n_f64 (a);
57 }
58
59 int __attribute__ ((noinline))
test_vdup_n_f64()60 test_vdup_n_f64 ()
61 {
62 float64_t a = 1.0;
63 float64x1_t b;
64 float64_t c[1];
65 int i;
66
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;
73 }
74
75 float64x2_t __attribute__ ((noinline))
wrap_vdupq_n_f64(float64_t a)76 wrap_vdupq_n_f64 (float64_t a)
77 {
78 return vdupq_n_f64 (a);
79 }
80
81 int __attribute__ ((noinline))
test_vdupq_n_f64()82 test_vdupq_n_f64 ()
83 {
84 float64_t a = 1.0;
85 float64x2_t b;
86 float64_t c[2];
87 int i;
88
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;
95 }
96
97 poly8x8_t __attribute__ ((noinline))
wrap_vdup_n_p8(poly8_t a)98 wrap_vdup_n_p8 (poly8_t a)
99 {
100 return vdup_n_p8 (a);
101 }
102
103 int __attribute__ ((noinline))
test_vdup_n_p8()104 test_vdup_n_p8 ()
105 {
106 poly8_t a = 1;
107 poly8x8_t b;
108 poly8_t c[8];
109 int i;
110
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;
117 }
118
119 poly8x16_t __attribute__ ((noinline))
wrap_vdupq_n_p8(poly8_t a)120 wrap_vdupq_n_p8 (poly8_t a)
121 {
122 return vdupq_n_p8 (a);
123 }
124
125 int __attribute__ ((noinline))
test_vdupq_n_p8()126 test_vdupq_n_p8 ()
127 {
128 poly8_t a = 1;
129 poly8x16_t b;
130 poly8_t c[16];
131 int i;
132
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;
139 }
140
141 int8x8_t __attribute__ ((noinline))
wrap_vdup_n_s8(int8_t a)142 wrap_vdup_n_s8 (int8_t a)
143 {
144 return vdup_n_s8 (a);
145 }
146
147 int __attribute__ ((noinline))
test_vdup_n_s8()148 test_vdup_n_s8 ()
149 {
150 int8_t a = 1;
151 int8x8_t b;
152 int8_t c[8];
153 int i;
154
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;
161 }
162
163 int8x16_t __attribute__ ((noinline))
wrap_vdupq_n_s8(int8_t a)164 wrap_vdupq_n_s8 (int8_t a)
165 {
166 return vdupq_n_s8 (a);
167 }
168
169 int __attribute__ ((noinline))
test_vdupq_n_s8()170 test_vdupq_n_s8 ()
171 {
172 int8_t a = 1;
173 int8x16_t b;
174 int8_t c[16];
175 int i;
176
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;
183 }
184
185 uint8x8_t __attribute__ ((noinline))
wrap_vdup_n_u8(uint8_t a)186 wrap_vdup_n_u8 (uint8_t a)
187 {
188 return vdup_n_u8 (a);
189 }
190
191 int __attribute__ ((noinline))
test_vdup_n_u8()192 test_vdup_n_u8 ()
193 {
194 uint8_t a = 1;
195 uint8x8_t b;
196 uint8_t c[8];
197 int i;
198
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;
205 }
206
207 uint8x16_t __attribute__ ((noinline))
wrap_vdupq_n_u8(uint8_t a)208 wrap_vdupq_n_u8 (uint8_t a)
209 {
210 return vdupq_n_u8 (a);
211 }
212
213 int __attribute__ ((noinline))
test_vdupq_n_u8()214 test_vdupq_n_u8 ()
215 {
216 uint8_t a = 1;
217 uint8x16_t b;
218 uint8_t c[16];
219 int i;
220
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;
227 }
228
229 poly16x4_t __attribute__ ((noinline))
wrap_vdup_n_p16(poly16_t a)230 wrap_vdup_n_p16 (poly16_t a)
231 {
232 return vdup_n_p16 (a);
233 }
234
235 int __attribute__ ((noinline))
test_vdup_n_p16()236 test_vdup_n_p16 ()
237 {
238 poly16_t a = 1;
239 poly16x4_t b;
240 poly16_t c[4];
241 int i;
242
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;
249 }
250
251 poly16x8_t __attribute__ ((noinline))
wrap_vdupq_n_p16(poly16_t a)252 wrap_vdupq_n_p16 (poly16_t a)
253 {
254 return vdupq_n_p16 (a);
255 }
256
257 int __attribute__ ((noinline))
test_vdupq_n_p16()258 test_vdupq_n_p16 ()
259 {
260 poly16_t a = 1;
261 poly16x8_t b;
262 poly16_t c[8];
263 int i;
264
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;
271 }
272
273 int16x4_t __attribute__ ((noinline))
wrap_vdup_n_s16(int16_t a)274 wrap_vdup_n_s16 (int16_t a)
275 {
276 return vdup_n_s16 (a);
277 }
278
279 int __attribute__ ((noinline))
test_vdup_n_s16()280 test_vdup_n_s16 ()
281 {
282 int16_t a = 1;
283 int16x4_t b;
284 int16_t c[4];
285 int i;
286
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;
293 }
294
295 int16x8_t __attribute__ ((noinline))
wrap_vdupq_n_s16(int16_t a)296 wrap_vdupq_n_s16 (int16_t a)
297 {
298 return vdupq_n_s16 (a);
299 }
300
301 int __attribute__ ((noinline))
test_vdupq_n_s16()302 test_vdupq_n_s16 ()
303 {
304 int16_t a = 1;
305 int16x8_t b;
306 int16_t c[8];
307 int i;
308
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;
315 }
316
317 uint16x4_t __attribute__ ((noinline))
wrap_vdup_n_u16(uint16_t a)318 wrap_vdup_n_u16 (uint16_t a)
319 {
320 return vdup_n_u16 (a);
321 }
322
323 int __attribute__ ((noinline))
test_vdup_n_u16()324 test_vdup_n_u16 ()
325 {
326 uint16_t a = 1;
327 uint16x4_t b;
328 uint16_t c[4];
329 int i;
330
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;
337 }
338
339 uint16x8_t __attribute__ ((noinline))
wrap_vdupq_n_u16(uint16_t a)340 wrap_vdupq_n_u16 (uint16_t a)
341 {
342 return vdupq_n_u16 (a);
343 }
344
345 int __attribute__ ((noinline))
test_vdupq_n_u16()346 test_vdupq_n_u16 ()
347 {
348 uint16_t a = 1;
349 uint16x8_t b;
350 uint16_t c[8];
351 int i;
352
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;
359 }
360
361 int32x2_t __attribute__ ((noinline))
wrap_vdup_n_s32(int32_t a)362 wrap_vdup_n_s32 (int32_t a)
363 {
364 return vdup_n_s32 (a);
365 }
366
367 int __attribute__ ((noinline))
test_vdup_n_s32()368 test_vdup_n_s32 ()
369 {
370 int32_t a = 1;
371 int32x2_t b;
372 int32_t c[2];
373 int i;
374
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;
381 }
382
383 int32x4_t __attribute__ ((noinline))
wrap_vdupq_n_s32(int32_t a)384 wrap_vdupq_n_s32 (int32_t a)
385 {
386 return vdupq_n_s32 (a);
387 }
388
389 int __attribute__ ((noinline))
test_vdupq_n_s32()390 test_vdupq_n_s32 ()
391 {
392 int32_t a = 1;
393 int32x4_t b;
394 int32_t c[4];
395 int i;
396
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;
403 }
404
405 uint32x2_t __attribute__ ((noinline))
wrap_vdup_n_u32(uint32_t a)406 wrap_vdup_n_u32 (uint32_t a)
407 {
408 return vdup_n_u32 (a);
409 }
410
411 int __attribute__ ((noinline))
test_vdup_n_u32()412 test_vdup_n_u32 ()
413 {
414 uint32_t a = 1;
415 uint32x2_t b;
416 uint32_t c[2];
417 int i;
418
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;
425 }
426
427 uint32x4_t __attribute__ ((noinline))
wrap_vdupq_n_u32(uint32_t a)428 wrap_vdupq_n_u32 (uint32_t a)
429 {
430 return vdupq_n_u32 (a);
431 }
432
433 int __attribute__ ((noinline))
test_vdupq_n_u32()434 test_vdupq_n_u32 ()
435 {
436 uint32_t a = 1;
437 uint32x4_t b;
438 uint32_t c[4];
439 int i;
440
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;
447 }
448
449 int64x1_t __attribute__ ((noinline))
wrap_vdup_n_s64(int64_t a)450 wrap_vdup_n_s64 (int64_t a)
451 {
452 return vdup_n_s64 (a);
453 }
454
455 int __attribute__ ((noinline))
test_vdup_n_s64()456 test_vdup_n_s64 ()
457 {
458 int64_t a = 1;
459 int64x1_t b;
460 int64_t c[1];
461 int i;
462
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;
469 }
470
471 int64x2_t __attribute__ ((noinline))
wrap_vdupq_n_s64(int64_t a)472 wrap_vdupq_n_s64 (int64_t a)
473 {
474 return vdupq_n_s64 (a);
475 }
476
477 int __attribute__ ((noinline))
test_vdupq_n_s64()478 test_vdupq_n_s64 ()
479 {
480 int64_t a = 1;
481 int64x2_t b;
482 int64_t c[2];
483 int i;
484
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;
491 }
492
493 uint64x1_t __attribute__ ((noinline))
wrap_vdup_n_u64(uint64_t a)494 wrap_vdup_n_u64 (uint64_t a)
495 {
496 return vdup_n_u64 (a);
497 }
498
499 int __attribute__ ((noinline))
test_vdup_n_u64()500 test_vdup_n_u64 ()
501 {
502 uint64_t a = 1;
503 uint64x1_t b;
504 uint64_t c[1];
505 int i;
506
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;
513 }
514
515 uint64x2_t __attribute__ ((noinline))
wrap_vdupq_n_u64(uint64_t a)516 wrap_vdupq_n_u64 (uint64_t a)
517 {
518 return vdupq_n_u64 (a);
519 }
520
521 int __attribute__ ((noinline))
test_vdupq_n_u64()522 test_vdupq_n_u64 ()
523 {
524 uint64_t a = 1;
525 uint64x2_t b;
526 uint64_t c[2];
527 int i;
528
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;
535 }
536
537 int
main()538 main ()
539 {
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;
589 }
590
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. */
593
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 } } */
596
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 } } */
599
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 } } */
602
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 } } */
605
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 } } */
608
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 } } */
611
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. */
615
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 } } */
618
619