| 1 |
/* Test SIMD shift works correctly. */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-O3 --save-temps" } */ |
| 4 |
|
| 5 |
#include "arm_neon.h" |
| 6 |
|
| 7 |
extern void abort (void); |
| 8 |
|
| 9 |
int __attribute__ ((noinline)) |
| 10 |
test_sshr64 () |
| 11 |
{ |
| 12 |
int64x1_t arg; |
| 13 |
int64x1_t result; |
| 14 |
int64_t got; |
| 15 |
int64_t exp; |
| 16 |
arg = vcreate_s64 (0x0000000080000000); |
| 17 |
result = vshr_n_s64 (arg, 64); |
| 18 |
got = vget_lane_s64 (result, 0); |
| 19 |
exp = 0; |
| 20 |
/* Expect: "result" = 0000000000000000. */ |
| 21 |
if (exp != got) |
| 22 |
return 1; |
| 23 |
return 0; |
| 24 |
} |
| 25 |
|
| 26 |
int __attribute__ ((noinline)) |
| 27 |
test_sshr64_neg () |
| 28 |
{ |
| 29 |
int64x1_t arg; |
| 30 |
int64x1_t result; |
| 31 |
int64_t got; |
| 32 |
int64_t exp; |
| 33 |
arg = vcreate_s64 (0xffffffff80000000); |
| 34 |
result = vshr_n_s64 (arg, 64); |
| 35 |
got = vget_lane_s64 (result, 0); |
| 36 |
exp = 0xffffffffffffffff; |
| 37 |
/* Expect: "result" = -1. */ |
| 38 |
if (exp != got) |
| 39 |
return 1; |
| 40 |
return 0; |
| 41 |
} |
| 42 |
|
| 43 |
int |
| 44 |
__attribute__ ((noinline)) |
| 45 |
test_other () |
| 46 |
{ |
| 47 |
int64x1_t arg; |
| 48 |
int64x1_t result; |
| 49 |
int64_t got; |
| 50 |
int64_t exp; |
| 51 |
arg = vcreate_s64 (0x0000000080000000); |
| 52 |
result = vshr_n_s64 (arg, 4); |
| 53 |
got = vget_lane_s64 (result, 0); |
| 54 |
exp = 0x0000000008000000; |
| 55 |
/* Expect: "result" = 0x0000000008000000. */ |
| 56 |
if (exp != got) |
| 57 |
return 1; |
| 58 |
return 0; |
| 59 |
} |
| 60 |
|
| 61 |
int __attribute__ ((noinline)) |
| 62 |
test_other_neg () |
| 63 |
{ |
| 64 |
int64x1_t arg; |
| 65 |
int64x1_t result; |
| 66 |
int64_t got; |
| 67 |
int64_t exp; |
| 68 |
arg = vcreate_s64 (0xffffffff80000000); |
| 69 |
result = vshr_n_s64 (arg, 4); |
| 70 |
got = vget_lane_s64 (result, 0); |
| 71 |
exp = 0xfffffffff8000000; |
| 72 |
/* Expect: "result" = 0xfffffffff8000000. */ |
| 73 |
if (exp != got) |
| 74 |
return 1; |
| 75 |
return 0; |
| 76 |
} |
| 77 |
|
| 78 |
int __attribute__ ((noinline)) |
| 79 |
test_no_sshr0 () |
| 80 |
{ |
| 81 |
int64x1_t arg; |
| 82 |
int64x1_t result; |
| 83 |
int64_t got; |
| 84 |
int64_t exp; |
| 85 |
arg = vcreate_s64 (0x0000000080000000); |
| 86 |
result = vshr_n_s64 (arg, 0); |
| 87 |
got = vget_lane_s64 (result, 0); |
| 88 |
exp = 0x0000000080000000; |
| 89 |
/* Expect: "result" = 0x0000000080000000. */ |
| 90 |
if (exp != got) |
| 91 |
return 1; |
| 92 |
return 0; |
| 93 |
} |
| 94 |
|
| 95 |
/* { dg-final { scan-assembler-not "sshr\\td\[0-9\]+, d\[0-9\]+, 0" } } */ |
| 96 |
int |
| 97 |
main () |
| 98 |
{ |
| 99 |
if (test_sshr64 ()) |
| 100 |
abort (); |
| 101 |
if (test_other ()) |
| 102 |
abort (); |
| 103 |
|
| 104 |
if (test_sshr64_neg ()) |
| 105 |
abort (); |
| 106 |
if (test_other_neg ()) |
| 107 |
abort (); |
| 108 |
|
| 109 |
if (test_no_sshr0 ()) |
| 110 |
abort (); |
| 111 |
|
| 112 |
return 0; |
| 113 |
} |
| 114 |
|