diff options
Diffstat (limited to 'gcc/testsuite/gcc.target/aarch64/sshr64_1.c')
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/sshr64_1.c | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/aarch64/sshr64_1.c b/gcc/testsuite/gcc.target/aarch64/sshr64_1.c new file mode 100644 index 00000000000..89c6096ad39 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sshr64_1.c @@ -0,0 +1,115 @@ +/* Test SIMD shift works correctly. */ +/* { dg-do run } */ +/* { dg-options "-O3 --save-temps" } */ + +#include "arm_neon.h" + +extern void abort (void); + +int __attribute__ ((noinline)) +test_sshr64 () +{ + int64x1_t arg; + int64x1_t result; + int64_t got; + int64_t exp; + arg = vcreate_s64 (0x0000000080000000); + result = vshr_n_s64 (arg, 64); + got = vget_lane_s64 (result, 0); + exp = 0; + /* Expect: "result" = 0000000000000000. */ + if (exp != got) + return 1; + return 0; +} + +int __attribute__ ((noinline)) +test_sshr64_neg () +{ + int64x1_t arg; + int64x1_t result; + int64_t got; + int64_t exp; + arg = vcreate_s64 (0xffffffff80000000); + result = vshr_n_s64 (arg, 64); + got = vget_lane_s64 (result, 0); + exp = 0xffffffffffffffff; + /* Expect: "result" = -1. */ + if (exp != got) + return 1; + return 0; +} + +int +__attribute__ ((noinline)) +test_other () +{ + int64x1_t arg; + int64x1_t result; + int64_t got; + int64_t exp; + arg = vcreate_s64 (0x0000000080000000); + result = vshr_n_s64 (arg, 4); + got = vget_lane_s64 (result, 0); + exp = 0x0000000008000000; + /* Expect: "result" = 0x0000000008000000. */ + if (exp != got) + return 1; + return 0; +} + +int __attribute__ ((noinline)) +test_other_neg () +{ + int64x1_t arg; + int64x1_t result; + int64_t got; + int64_t exp; + arg = vcreate_s64 (0xffffffff80000000); + result = vshr_n_s64 (arg, 4); + got = vget_lane_s64 (result, 0); + exp = 0xfffffffff8000000; + /* Expect: "result" = 0xfffffffff8000000. */ + if (exp != got) + return 1; + return 0; +} + +int __attribute__ ((noinline)) +test_no_sshr0 () +{ + int64x1_t arg; + int64x1_t result; + int64_t got; + int64_t exp; + arg = vcreate_s64 (0x0000000080000000); + result = vshr_n_s64 (arg, 0); + got = vget_lane_s64 (result, 0); + exp = 0x0000000080000000; + /* Expect: "result" = 0x0000000080000000. */ + if (exp != got) + return 1; + return 0; +} + +/* { dg-final { scan-assembler-not "sshr\\td\[0-9\]+, d\[0-9\]+, 0" } } */ +int +main () +{ + if (test_sshr64 ()) + abort (); + if (test_other ()) + abort (); + + if (test_sshr64_neg ()) + abort (); + if (test_other_neg ()) + abort (); + + if (test_no_sshr0 ()) + abort (); + + return 0; +} + +/* { dg-final { cleanup-saved-temps } } */ |