Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vqrshrun_high_n.c

raw
1 /* { dg-skip-if "" { arm*-*-* } } */
2
3 #include <arm_neon.h>
4 #include "arm-neon-ref.h"
5 #include "compute-ref-data.h"
6
7 /* Expected results with negative input. */
8 VECT_VAR_DECL(expected_neg,uint,8,16) [] = { 0xfe, 0xfe, 0xfe, 0xfe,
9 0xfe, 0xfe, 0xfe, 0xfe,
10 0x0, 0x0, 0x0, 0x0,
11 0x0, 0x0, 0x0, 0x0 };
12 VECT_VAR_DECL(expected_neg,uint,16,8) [] = { 0xfffd, 0xfffd, 0xfffd, 0xfffd,
13 0x0, 0x0, 0x0, 0x0 };
14 VECT_VAR_DECL(expected_neg,uint,32,4) [] = { 0xfffffffc, 0xfffffffc, 0x0, 0x0 };
15
16 /* Expected results with max input value shifted by 1. */
17 VECT_VAR_DECL(expected_max_sh1,uint,8,16) [] = { 0x7f, 0x7f, 0x7f, 0x7f,
18 0x7f, 0x7f, 0x7f, 0x7f,
19 0xff, 0xff, 0xff, 0xff,
20 0xff, 0xff, 0xff, 0xff };
21 VECT_VAR_DECL(expected_max_sh1,uint,16,8) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff,
22 0xffff, 0xffff, 0xffff, 0xffff };
23 VECT_VAR_DECL(expected_max_sh1,uint,32,4) [] = { 0x7fffffff, 0x7fffffff,
24 0xffffffff, 0xffffffff };
25
26 /* Expected results with max input value shifted by max amount. */
27 VECT_VAR_DECL(expected_max_shmax,uint,8,16) [] = { 0x7f, 0x7f, 0x7f, 0x7f,
28 0x7f, 0x7f, 0x7f, 0x7f,
29 0x80, 0x80, 0x80, 0x80,
30 0x80, 0x80, 0x80, 0x80 };
31 VECT_VAR_DECL(expected_max_shmax,uint,16,8) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff,
32 0x8000, 0x8000, 0x8000, 0x8000 };
33 VECT_VAR_DECL(expected_max_shmax,uint,32,4) [] = { 0x7fffffff, 0x7fffffff,
34 0x80000000, 0x80000000 };
35
36 /* Expected results with min input value shifted by max amount. */
37 VECT_VAR_DECL(expected_min_shmax,uint,8,16) [] = { 0x80, 0x80, 0x80, 0x80,
38 0x80, 0x80, 0x80, 0x80,
39 0x0, 0x0, 0x0, 0x0,
40 0x0, 0x0, 0x0, 0x0 };
41 VECT_VAR_DECL(expected_min_shmax,uint,16,8) [] = { 0x8000, 0x8000, 0x8000, 0x8000,
42 0x0, 0x0, 0x0, 0x0 };
43 VECT_VAR_DECL(expected_min_shmax,uint,32,4) [] = { 0x80000000, 0x80000000,
44 0x0, 0x0 };
45
46 /* Expected results with inputs in usual range. */
47 VECT_VAR_DECL(expected,uint,8,16) [] = { 0x12, 0x12, 0x12, 0x12,
48 0x12, 0x12, 0x12, 0x12,
49 0x49, 0x49, 0x49, 0x49,
50 0x49, 0x49, 0x49, 0x49 };
51 VECT_VAR_DECL(expected,uint,16,8) [] = { 0x4321, 0x4321, 0x4321, 0x4321,
52 0x0, 0x0, 0x0, 0x0 };
53 VECT_VAR_DECL(expected,uint,32,4) [] = { 0xdeadbeef, 0xdeadbeef,
54 0xdeadbf, 0xdeadbf };
55
56 #define INSN vqrshrun_high_n
57 #define TEST_MSG "VQRSHRUN_HIGH_N"
58
59 #define FNNAME1(NAME) void exec_ ## NAME (void)
60 #define FNNAME(NAME) FNNAME1(NAME)
61
62 FNNAME (INSN)
63 {
64 /* Basic test: y=vqrshrun_high_n(x,v), then store the result. */
65 #define TEST_VQRSHRUN_HIGH_N2(INSN, T1, T2, W, W2, N, N2, V) \
66 VECT_VAR(vector_res, uint, W2, N2) = \
67 INSN##_##T2##W(VECT_VAR(vector1, uint, W2, N), \
68 VECT_VAR(vector2, T1, W, N), V); \
69 vst1q_u##W2(VECT_VAR(result, uint, W2, N2), \
70 VECT_VAR(vector_res, uint, W2, N2)); \
71
72 /* Two auxliary macros are necessary to expand INSN */
73 #define TEST_VQRSHRUN_HIGH_N1(INSN, T1, T2, W, W2, N, N2, V) \
74 TEST_VQRSHRUN_HIGH_N2(INSN, T1, T2, W, W2, N, N2, V)
75
76 #define TEST_VQRSHRUN_HIGH_N(T1, T2, W, W2, N, N2, V) \
77 TEST_VQRSHRUN_HIGH_N1(INSN, T1, T2, W, W2, N, N2, V)
78
79
80 DECL_VARIABLE(vector1, uint, 8, 8);
81 DECL_VARIABLE(vector1, uint, 16, 4);
82 DECL_VARIABLE(vector1, uint, 32, 2);
83
84 /* vector is twice as large as vector_res. */
85 DECL_VARIABLE(vector2, int, 16, 8);
86 DECL_VARIABLE(vector2, int, 32, 4);
87 DECL_VARIABLE(vector2, int, 64, 2);
88
89 DECL_VARIABLE(vector_res, uint, 8, 16);
90 DECL_VARIABLE(vector_res, uint, 16, 8);
91 DECL_VARIABLE(vector_res, uint, 32, 4);
92
93 clean_results ();
94
95 /* Fill input vector with negative values, to check saturation on
96 limits. */
97 VDUP(vector1, , uint, u, 8, 8, -2);
98 VDUP(vector1, , uint, u, 16, 4, -3);
99 VDUP(vector1, , uint, u, 32, 2, -4);
100
101 VDUP(vector2, q, int, s, 16, 8, -2);
102 VDUP(vector2, q, int, s, 32, 4, -3);
103 VDUP(vector2, q, int, s, 64, 2, -4);
104
105 /* Choose shift amount arbitrarily. */
106 #define CMT " (negative input)"
107 TEST_VQRSHRUN_HIGH_N(int, s, 16, 8, 8, 16, 3);
108 TEST_VQRSHRUN_HIGH_N(int, s, 32, 16, 4, 8, 4);
109 TEST_VQRSHRUN_HIGH_N(int, s, 64, 32, 2, 4, 2);
110
111 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_neg, CMT);
112 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_neg, CMT);
113 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_neg, CMT);
114
115
116 /* Fill input vector with max value, to check saturation on
117 limits. */
118 VDUP(vector1, , uint, u, 8, 8, 0x7F);
119 VDUP(vector1, , uint, u, 16, 4, 0x7FFF);
120 VDUP(vector1, , uint, u, 32, 2, 0x7FFFFFFFLL);
121
122 VDUP(vector2, q, int, s, 16, 8, 0x7FFF);
123 VDUP(vector2, q, int, s, 32, 4, 0x7FFFFFFF);
124 VDUP(vector2, q, int, s, 64, 2, 0x7FFFFFFFFFFFFFFFLL);
125
126 /* shift by 1. */
127 #undef CMT
128 #define CMT " (check cumulative saturation: shift by 1)"
129 TEST_VQRSHRUN_HIGH_N(int, s, 16, 8, 8, 16, 1);
130 TEST_VQRSHRUN_HIGH_N(int, s, 32, 16, 4, 8, 1);
131 TEST_VQRSHRUN_HIGH_N(int, s, 64, 32, 2, 4, 1);
132
133 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_max_sh1, CMT);
134 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_max_sh1, CMT);
135 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_max_sh1, CMT);
136
137
138 /* shift by max. */
139 #undef CMT
140 #define CMT " (check cumulative saturation: shift by max, positive input)"
141 TEST_VQRSHRUN_HIGH_N(int, s, 16, 8, 8, 16, 8);
142 TEST_VQRSHRUN_HIGH_N(int, s, 32, 16, 4, 8, 16);
143 TEST_VQRSHRUN_HIGH_N(int, s, 64, 32, 2, 4, 32);
144
145 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_max_shmax, CMT);
146 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_max_shmax, CMT);
147 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_max_shmax, CMT);
148
149
150 /* Fill input vector with min value, to check saturation on limits. */
151 VDUP(vector1, , uint, u, 8, 8, 0x80);
152 VDUP(vector1, , uint, u, 16, 4, 0x8000);
153 VDUP(vector1, , uint, u, 32, 2, 0x80000000LL);
154
155 VDUP(vector2, q, int, s, 16, 8, 0x8000);
156 VDUP(vector2, q, int, s, 32, 4, 0x80000000);
157 VDUP(vector2, q, int, s, 64, 2, 0x8000000000000000LL);
158
159 /* shift by max */
160 #undef CMT
161 #define CMT " (check cumulative saturation: shift by max, negative input)"
162 TEST_VQRSHRUN_HIGH_N(int, s, 16, 8, 8, 16, 8);
163 TEST_VQRSHRUN_HIGH_N(int, s, 32, 16, 4, 8, 16);
164 TEST_VQRSHRUN_HIGH_N(int, s, 64, 32, 2, 4, 32);
165
166 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_min_shmax, CMT);
167 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_min_shmax, CMT);
168 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_min_shmax, CMT);
169
170
171 /* Fill input vector with positive values, to check normal case. */
172 VDUP(vector1, , uint, u, 8, 8, 0x12);
173 VDUP(vector1, , uint, u, 16, 4, 0x4321);
174 VDUP(vector1, , uint, u, 32, 2, 0xDEADBEEF);
175
176 VDUP(vector2, q, int, s, 16, 8, 0x1234);
177 VDUP(vector2, q, int, s, 32, 4, 0x87654321);
178 VDUP(vector2, q, int, s, 64, 2, 0xDEADBEEF);
179
180 /* shift arbitrary amount. */
181 #undef CMT
182 #define CMT ""
183 TEST_VQRSHRUN_HIGH_N(int, s, 16, 8, 8, 16, 6);
184 TEST_VQRSHRUN_HIGH_N(int, s, 32, 16, 4, 8, 7);
185 TEST_VQRSHRUN_HIGH_N(int, s, 64, 32, 2, 4, 8);
186
187 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, CMT);
188 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, CMT);
189 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, CMT);
190 }
191
192 int main (void)
193 {
194 exec_vqrshrun_high_n ();
195 return 0;
196 }