| 1 |
/* { dg-do run { target aarch64_sve_hw } } */ |
| 2 |
/* { dg-options "-O2" } */ |
| 3 |
|
| 4 |
#include <arm_sve.h> |
| 5 |
|
| 6 |
#ifndef TYPE |
| 7 |
#define TYPE svint8_t |
| 8 |
#define DUPQ svdupq_lane_s8 |
| 9 |
#define INDEX svindex_s8 |
| 10 |
#define COUNT 16 |
| 11 |
#endif |
| 12 |
|
| 13 |
#define BASE 42 |
| 14 |
|
| 15 |
TYPE __attribute__ ((noipa)) |
| 16 |
dupq_var (TYPE x, uint64_t y) |
| 17 |
{ |
| 18 |
return DUPQ (x, y); |
| 19 |
} |
| 20 |
|
| 21 |
TYPE __attribute__ ((noipa)) |
| 22 |
dupq_0 (TYPE x) |
| 23 |
{ |
| 24 |
return DUPQ (x, 0); |
| 25 |
} |
| 26 |
|
| 27 |
TYPE __attribute__ ((noipa)) |
| 28 |
dupq_1 (TYPE x) |
| 29 |
{ |
| 30 |
return DUPQ (x, 1); |
| 31 |
} |
| 32 |
|
| 33 |
TYPE __attribute__ ((noipa)) |
| 34 |
dupq_2 (TYPE x) |
| 35 |
{ |
| 36 |
return DUPQ (x, 2); |
| 37 |
} |
| 38 |
|
| 39 |
TYPE __attribute__ ((noipa)) |
| 40 |
dupq_3 (TYPE x) |
| 41 |
{ |
| 42 |
return DUPQ (x, 3); |
| 43 |
} |
| 44 |
|
| 45 |
TYPE __attribute__ ((noipa)) |
| 46 |
dupq_4 (TYPE x) |
| 47 |
{ |
| 48 |
return DUPQ (x, 4); |
| 49 |
} |
| 50 |
|
| 51 |
void __attribute__ ((noipa)) |
| 52 |
check (TYPE x, uint64_t y) |
| 53 |
{ |
| 54 |
svbool_t pg = svptrue_b8 (); |
| 55 |
if (y * 2 >= svcntd ()) |
| 56 |
{ |
| 57 |
if (svptest_any (pg, svcmpne (pg, x, 0))) |
| 58 |
__builtin_abort (); |
| 59 |
} |
| 60 |
else |
| 61 |
{ |
| 62 |
TYPE repeat = svand_x (pg, INDEX (0, 1), COUNT - 1); |
| 63 |
TYPE expected = svadd_x (pg, repeat, BASE + y * COUNT); |
| 64 |
if (svptest_any (pg, svcmpne (pg, x, expected))) |
| 65 |
__builtin_abort (); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
int |
| 70 |
main () |
| 71 |
{ |
| 72 |
TYPE x = INDEX (BASE, 1); |
| 73 |
|
| 74 |
check (dupq_0 (x), 0); |
| 75 |
check (dupq_1 (x), 1); |
| 76 |
check (dupq_2 (x), 2); |
| 77 |
check (dupq_3 (x), 3); |
| 78 |
check (dupq_4 (x), 4); |
| 79 |
|
| 80 |
for (int i = 0; i < 63; ++i) |
| 81 |
{ |
| 82 |
check (dupq_var (x, i), i); |
| 83 |
check (dupq_var (x, (uint64_t) 1 << i), (uint64_t) 1 << i); |
| 84 |
} |
| 85 |
|
| 86 |
return 0; |
| 87 |
} |