| 1 |
/* Test vqabs_s64 intrinsics work correctly. */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "--save-temps" } */ |
| 4 |
|
| 5 |
#include <arm_neon.h> |
| 6 |
|
| 7 |
extern void abort (void); |
| 8 |
|
| 9 |
int __attribute__ ((noinline)) |
| 10 |
test_vqabs_s64 (int64x1_t passed, int64_t expected) |
| 11 |
{ |
| 12 |
return vget_lane_s64 (vqabs_s64 (passed), 0) != expected; |
| 13 |
} |
| 14 |
|
| 15 |
int __attribute__ ((noinline)) |
| 16 |
test_vqabsd_s64 (int64_t passed, int64_t expected) |
| 17 |
{ |
| 18 |
return vqabsd_s64 (passed) != expected; |
| 19 |
} |
| 20 |
|
| 21 |
/* { dg-final { scan-assembler-times "sqabs\\td\[0-9\]+, d\[0-9\]+" 2 } } */ |
| 22 |
|
| 23 |
int |
| 24 |
main (int argc, char **argv) |
| 25 |
{ |
| 26 |
/* Basic test. */ |
| 27 |
if (test_vqabs_s64 (vcreate_s64 (-1), 1)) |
| 28 |
abort (); |
| 29 |
if (test_vqabsd_s64 (-1, 1)) |
| 30 |
abort (); |
| 31 |
|
| 32 |
/* Getting absolute value of min int64_t. |
| 33 |
Note, exact result cannot be represented in int64_t, |
| 34 |
so max int64_t is expected. */ |
| 35 |
if (test_vqabs_s64 (vcreate_s64 (0x8000000000000000), 0x7fffffffffffffff)) |
| 36 |
abort (); |
| 37 |
if (test_vqabsd_s64 (0x8000000000000000, 0x7fffffffffffffff)) |
| 38 |
abort (); |
| 39 |
|
| 40 |
/* Another input that gets max int64_t. */ |
| 41 |
if (test_vqabs_s64 (vcreate_s64 (0x8000000000000001), 0x7fffffffffffffff)) |
| 42 |
abort (); |
| 43 |
if (test_vqabsd_s64 (0x8000000000000001, 0x7fffffffffffffff)) |
| 44 |
abort (); |
| 45 |
|
| 46 |
/* Checking that large positive numbers stay the same. */ |
| 47 |
if (test_vqabs_s64 (vcreate_s64 (0x7fffffffffffffff), 0x7fffffffffffffff)) |
| 48 |
abort (); |
| 49 |
if (test_vqabsd_s64 (0x7fffffffffffffff, 0x7fffffffffffffff)) |
| 50 |
abort (); |
| 51 |
|
| 52 |
return 0; |
| 53 |
} |