1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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 } } */
|