2 #include "arm-neon-ref.h"
3 #include "compute-ref-data.h"
5 /* Expected values of cumulative_saturation flag. */
6 int VECT_VAR(expected_cumulative_sat
,int,8,8) = 0;
7 int VECT_VAR(expected_cumulative_sat
,int,16,4) = 0;
8 int VECT_VAR(expected_cumulative_sat
,int,32,2) = 0;
9 int VECT_VAR(expected_cumulative_sat
,int,64,1) = 0;
10 int VECT_VAR(expected_cumulative_sat
,uint
,8,8) = 1;
11 int VECT_VAR(expected_cumulative_sat
,uint
,16,4) = 1;
12 int VECT_VAR(expected_cumulative_sat
,uint
,32,2) = 1;
13 int VECT_VAR(expected_cumulative_sat
,uint
,64,1) = 1;
14 int VECT_VAR(expected_cumulative_sat
,int,8,16) = 0;
15 int VECT_VAR(expected_cumulative_sat
,int,16,8) = 0;
16 int VECT_VAR(expected_cumulative_sat
,int,32,4) = 0;
17 int VECT_VAR(expected_cumulative_sat
,int,64,2) = 0;
18 int VECT_VAR(expected_cumulative_sat
,uint
,8,16) = 1;
19 int VECT_VAR(expected_cumulative_sat
,uint
,16,8) = 1;
20 int VECT_VAR(expected_cumulative_sat
,uint
,32,4) = 1;
21 int VECT_VAR(expected_cumulative_sat
,uint
,64,2) = 1;
23 /* Expected results. */
24 VECT_VAR_DECL(expected
,int,8,8) [] = { 0xc0, 0xc4, 0xc8, 0xcc,
25 0xd0, 0xd4, 0xd8, 0xdc };
26 VECT_VAR_DECL(expected
,int,16,4) [] = { 0xffe0, 0xffe2, 0xffe4, 0xffe6 };
27 VECT_VAR_DECL(expected
,int,32,2) [] = { 0xffffffe0, 0xffffffe2 };
28 VECT_VAR_DECL(expected
,int,64,1) [] = { 0xffffffffffffffc0 };
29 VECT_VAR_DECL(expected
,uint
,8,8) [] = { 0xff, 0xff, 0xff, 0xff,
30 0xff, 0xff, 0xff, 0xff };
31 VECT_VAR_DECL(expected
,uint
,16,4) [] = { 0xffff, 0xffff, 0xffff, 0xffff };
32 VECT_VAR_DECL(expected
,uint
,32,2) [] = { 0xffffffff, 0xffffffff };
33 VECT_VAR_DECL(expected
,uint
,64,1) [] = { 0xffffffffffffffff };
34 VECT_VAR_DECL(expected
,int,8,16) [] = { 0xc0, 0xc4, 0xc8, 0xcc,
35 0xd0, 0xd4, 0xd8, 0xdc,
36 0xe0, 0xe4, 0xe8, 0xec,
37 0xf0, 0xf4, 0xf8, 0xfc };
38 VECT_VAR_DECL(expected
,int,16,8) [] = { 0xffe0, 0xffe2, 0xffe4, 0xffe6,
39 0xffe8, 0xffea, 0xffec, 0xffee };
40 VECT_VAR_DECL(expected
,int,32,4) [] = { 0xffffffe0, 0xffffffe2,
41 0xffffffe4, 0xffffffe6 };
42 VECT_VAR_DECL(expected
,int,64,2) [] = { 0xffffffffffffffc0, 0xffffffffffffffc4 };
43 VECT_VAR_DECL(expected
,uint
,8,16) [] = { 0xff, 0xff, 0xff, 0xff,
44 0xff, 0xff, 0xff, 0xff,
45 0xff, 0xff, 0xff, 0xff,
46 0xff, 0xff, 0xff, 0xff };
47 VECT_VAR_DECL(expected
,uint
,16,8) [] = { 0xffff, 0xffff, 0xffff, 0xffff,
48 0xffff, 0xffff, 0xffff, 0xffff };
49 VECT_VAR_DECL(expected
,uint
,32,4) [] = { 0xffffffff, 0xffffffff,
50 0xffffffff, 0xffffffff };
51 VECT_VAR_DECL(expected
,uint
,64,2) [] = { 0xffffffffffffffff,
54 /* Expected values of cumulative_saturation flag with max positive input. */
55 int VECT_VAR(expected_cumulative_sat_max
,int,8,8) = 1;
56 int VECT_VAR(expected_cumulative_sat_max
,int,16,4) = 1;
57 int VECT_VAR(expected_cumulative_sat_max
,int,32,2) = 1;
58 int VECT_VAR(expected_cumulative_sat_max
,int,64,1) = 1;
59 int VECT_VAR(expected_cumulative_sat_max
,uint
,8,8) = 1;
60 int VECT_VAR(expected_cumulative_sat_max
,uint
,16,4) = 1;
61 int VECT_VAR(expected_cumulative_sat_max
,uint
,32,2) = 1;
62 int VECT_VAR(expected_cumulative_sat_max
,uint
,64,1) = 1;
63 int VECT_VAR(expected_cumulative_sat_max
,int,8,16) = 1;
64 int VECT_VAR(expected_cumulative_sat_max
,int,16,8) = 1;
65 int VECT_VAR(expected_cumulative_sat_max
,int,32,4) = 1;
66 int VECT_VAR(expected_cumulative_sat_max
,int,64,2) = 1;
67 int VECT_VAR(expected_cumulative_sat_max
,uint
,8,16) = 1;
68 int VECT_VAR(expected_cumulative_sat_max
,uint
,16,8) = 1;
69 int VECT_VAR(expected_cumulative_sat_max
,uint
,32,4) = 1;
70 int VECT_VAR(expected_cumulative_sat_max
,uint
,64,2) = 1;
72 /* Expected results with max positive input. */
73 VECT_VAR_DECL(expected_max
,int,8,8) [] = { 0x7f, 0x7f, 0x7f, 0x7f,
74 0x7f, 0x7f, 0x7f, 0x7f };
75 VECT_VAR_DECL(expected_max
,int,16,4) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff };
76 VECT_VAR_DECL(expected_max
,int,32,2) [] = { 0x7fffffff, 0x7fffffff };
77 VECT_VAR_DECL(expected_max
,int,64,1) [] = { 0x7fffffffffffffff };
78 VECT_VAR_DECL(expected_max
,uint
,8,8) [] = { 0xff, 0xff, 0xff, 0xff,
79 0xff, 0xff, 0xff, 0xff };
80 VECT_VAR_DECL(expected_max
,uint
,16,4) [] = { 0xffff, 0xffff, 0xffff, 0xffff };
81 VECT_VAR_DECL(expected_max
,uint
,32,2) [] = { 0xffffffff, 0xffffffff };
82 VECT_VAR_DECL(expected_max
,uint
,64,1) [] = { 0xffffffffffffffff };
83 VECT_VAR_DECL(expected_max
,int,8,16) [] = { 0x7f, 0x7f, 0x7f, 0x7f,
84 0x7f, 0x7f, 0x7f, 0x7f,
85 0x7f, 0x7f, 0x7f, 0x7f,
86 0x7f, 0x7f, 0x7f, 0x7f };
87 VECT_VAR_DECL(expected_max
,int,16,8) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff,
88 0x7fff, 0x7fff, 0x7fff, 0x7fff };
89 VECT_VAR_DECL(expected_max
,int,32,4) [] = { 0x7fffffff, 0x7fffffff,
90 0x7fffffff, 0x7fffffff };
91 VECT_VAR_DECL(expected_max
,int,64,2) [] = { 0x7fffffffffffffff,
93 VECT_VAR_DECL(expected_max
,uint
,8,16) [] = { 0xff, 0xff, 0xff, 0xff,
94 0xff, 0xff, 0xff, 0xff,
95 0xff, 0xff, 0xff, 0xff,
96 0xff, 0xff, 0xff, 0xff };
97 VECT_VAR_DECL(expected_max
,uint
,16,8) [] = { 0xffff, 0xffff, 0xffff, 0xffff,
98 0xffff, 0xffff, 0xffff, 0xffff };
99 VECT_VAR_DECL(expected_max
,uint
,32,4) [] = { 0xffffffff, 0xffffffff,
100 0xffffffff, 0xffffffff };
101 VECT_VAR_DECL(expected_max
,uint
,64,2) [] = { 0xffffffffffffffff,
102 0xffffffffffffffff };
105 #define TEST_MSG "VQSHL_N/VQSHLQ_N"
107 #define FNNAME1(NAME) void exec_ ## NAME ##_n (void)
108 #define FNNAME(NAME) FNNAME1(NAME)
112 /* Basic test: v2=vqshl_n(v1,v), then store the result. */
113 #define TEST_VQSHL_N2(INSN, Q, T1, T2, W, N, V, EXPECTED_CUMULATIVE_SAT, CMT) \
114 Set_Neon_Cumulative_Sat(0, VECT_VAR(vector_res, T1, W, N)); \
115 VECT_VAR(vector_res, T1, W, N) = \
116 INSN##Q##_n_##T2##W(VECT_VAR(vector, T1, W, N), \
118 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \
119 VECT_VAR(vector_res, T1, W, N)); \
120 CHECK_CUMULATIVE_SAT(TEST_MSG, T1, W, N, EXPECTED_CUMULATIVE_SAT, CMT)
122 /* Two auxliary macros are necessary to expand INSN */
123 #define TEST_VQSHL_N1(INSN, T3, Q, T1, T2, W, N, EXPECTED_CUMULATIVE_SAT, CMT) \
124 TEST_VQSHL_N2(INSN, T3, Q, T1, T2, W, N, EXPECTED_CUMULATIVE_SAT, CMT)
126 #define TEST_VQSHL_N(T3, Q, T1, T2, W, N, EXPECTED_CUMULATIVE_SAT, CMT) \
127 TEST_VQSHL_N1(INSN, T3, Q, T1, T2, W, N, EXPECTED_CUMULATIVE_SAT, CMT)
129 DECL_VARIABLE_ALL_VARIANTS(vector
);
130 DECL_VARIABLE_ALL_VARIANTS(vector_res
);
134 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD
, vector
, buffer
);
136 /* Choose shift amount arbitrarily. */
138 TEST_VQSHL_N(, int, s
, 8, 8, 2, expected_cumulative_sat
, CMT
);
139 TEST_VQSHL_N(, int, s
, 16, 4, 1, expected_cumulative_sat
, CMT
);
140 TEST_VQSHL_N(, int, s
, 32, 2, 1, expected_cumulative_sat
, CMT
);
141 TEST_VQSHL_N(, int, s
, 64, 1, 2, expected_cumulative_sat
, CMT
);
142 TEST_VQSHL_N(, uint
, u
, 8, 8, 3, expected_cumulative_sat
, CMT
);
143 TEST_VQSHL_N(, uint
, u
, 16, 4, 2, expected_cumulative_sat
, CMT
);
144 TEST_VQSHL_N(, uint
, u
, 32, 2, 3, expected_cumulative_sat
, CMT
);
145 TEST_VQSHL_N(, uint
, u
, 64, 1, 3, expected_cumulative_sat
, CMT
);
147 TEST_VQSHL_N(q
, int, s
, 8, 16, 2, expected_cumulative_sat
, CMT
);
148 TEST_VQSHL_N(q
, int, s
, 16, 8, 1, expected_cumulative_sat
, CMT
);
149 TEST_VQSHL_N(q
, int, s
, 32, 4, 1, expected_cumulative_sat
, CMT
);
150 TEST_VQSHL_N(q
, int, s
, 64, 2, 2, expected_cumulative_sat
, CMT
);
151 TEST_VQSHL_N(q
, uint
, u
, 8, 16, 3, expected_cumulative_sat
, CMT
);
152 TEST_VQSHL_N(q
, uint
, u
, 16, 8, 2, expected_cumulative_sat
, CMT
);
153 TEST_VQSHL_N(q
, uint
, u
, 32, 4, 3, expected_cumulative_sat
, CMT
);
154 TEST_VQSHL_N(q
, uint
, u
, 64, 2, 3, expected_cumulative_sat
, CMT
);
156 CHECK(TEST_MSG
, int, 8, 8, PRIx8
, expected
, CMT
);
157 CHECK(TEST_MSG
, int, 16, 4, PRIx16
, expected
, CMT
);
158 CHECK(TEST_MSG
, int, 32, 2, PRIx32
, expected
, CMT
);
159 CHECK(TEST_MSG
, int, 64, 1, PRIx64
, expected
, CMT
);
160 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected
, CMT
);
161 CHECK(TEST_MSG
, uint
, 16, 4, PRIx16
, expected
, CMT
);
162 CHECK(TEST_MSG
, uint
, 32, 2, PRIx32
, expected
, CMT
);
163 CHECK(TEST_MSG
, uint
, 64, 1, PRIx64
, expected
, CMT
);
164 CHECK(TEST_MSG
, int, 8, 16, PRIx8
, expected
, CMT
);
165 CHECK(TEST_MSG
, int, 16, 8, PRIx16
, expected
, CMT
);
166 CHECK(TEST_MSG
, int, 32, 4, PRIx32
, expected
, CMT
);
167 CHECK(TEST_MSG
, int, 64, 2, PRIx64
, expected
, CMT
);
168 CHECK(TEST_MSG
, uint
, 8, 16, PRIx8
, expected
, CMT
);
169 CHECK(TEST_MSG
, uint
, 16, 8, PRIx16
, expected
, CMT
);
170 CHECK(TEST_MSG
, uint
, 32, 4, PRIx32
, expected
, CMT
);
171 CHECK(TEST_MSG
, uint
, 64, 2, PRIx64
, expected
, CMT
);
174 /* Fill input vector with max value, to check saturation on limits. */
175 VDUP(vector
, , int, s
, 8, 8, 0x7F);
176 VDUP(vector
, , int, s
, 16, 4, 0x7FFF);
177 VDUP(vector
, , int, s
, 32, 2, 0x7FFFFFFF);
178 VDUP(vector
, , int, s
, 64, 1, 0x7FFFFFFFFFFFFFFFLL
);
179 VDUP(vector
, , uint
, u
, 8, 8, 0xFF);
180 VDUP(vector
, , uint
, u
, 16, 4, 0xFFFF);
181 VDUP(vector
, , uint
, u
, 32, 2, 0xFFFFFFFF);
182 VDUP(vector
, , uint
, u
, 64, 1, 0xFFFFFFFFFFFFFFFFULL
);
183 VDUP(vector
, q
, int, s
, 8, 16, 0x7F);
184 VDUP(vector
, q
, int, s
, 16, 8, 0x7FFF);
185 VDUP(vector
, q
, int, s
, 32, 4, 0x7FFFFFFF);
186 VDUP(vector
, q
, int, s
, 64, 2, 0x7FFFFFFFFFFFFFFFLL
);
187 VDUP(vector
, q
, uint
, u
, 8, 16, 0xFF);
188 VDUP(vector
, q
, uint
, u
, 16, 8, 0xFFFF);
189 VDUP(vector
, q
, uint
, u
, 32, 4, 0xFFFFFFFF);
190 VDUP(vector
, q
, uint
, u
, 64, 2, 0xFFFFFFFFFFFFFFFFULL
);
193 #define CMT " (with max input)"
194 TEST_VQSHL_N(, int, s
, 8, 8, 2, expected_cumulative_sat_max
, CMT
);
195 TEST_VQSHL_N(, int, s
, 16, 4, 1, expected_cumulative_sat_max
, CMT
);
196 TEST_VQSHL_N(, int, s
, 32, 2, 1, expected_cumulative_sat_max
, CMT
);
197 TEST_VQSHL_N(, int, s
, 64, 1, 2, expected_cumulative_sat_max
, CMT
);
198 TEST_VQSHL_N(, uint
, u
, 8, 8, 3, expected_cumulative_sat_max
, CMT
);
199 TEST_VQSHL_N(, uint
, u
, 16, 4, 2, expected_cumulative_sat_max
, CMT
);
200 TEST_VQSHL_N(, uint
, u
, 32, 2, 3, expected_cumulative_sat_max
, CMT
);
201 TEST_VQSHL_N(, uint
, u
, 64, 1, 3, expected_cumulative_sat_max
, CMT
);
203 TEST_VQSHL_N(q
, int, s
, 8, 16, 2, expected_cumulative_sat_max
, CMT
);
204 TEST_VQSHL_N(q
, int, s
, 16, 8, 1, expected_cumulative_sat_max
, CMT
);
205 TEST_VQSHL_N(q
, int, s
, 32, 4, 1, expected_cumulative_sat_max
, CMT
);
206 TEST_VQSHL_N(q
, int, s
, 64, 2, 2, expected_cumulative_sat_max
, CMT
);
207 TEST_VQSHL_N(q
, uint
, u
, 8, 16, 3, expected_cumulative_sat_max
, CMT
);
208 TEST_VQSHL_N(q
, uint
, u
, 16, 8, 2, expected_cumulative_sat_max
, CMT
);
209 TEST_VQSHL_N(q
, uint
, u
, 32, 4, 3, expected_cumulative_sat_max
, CMT
);
210 TEST_VQSHL_N(q
, uint
, u
, 64, 2, 3, expected_cumulative_sat_max
, CMT
);
212 CHECK(TEST_MSG
, int, 8, 8, PRIx8
, expected_max
, CMT
);
213 CHECK(TEST_MSG
, int, 16, 4, PRIx16
, expected_max
, CMT
);
214 CHECK(TEST_MSG
, int, 32, 2, PRIx32
, expected_max
, CMT
);
215 CHECK(TEST_MSG
, int, 64, 1, PRIx64
, expected_max
, CMT
);
216 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected_max
, CMT
);
217 CHECK(TEST_MSG
, uint
, 16, 4, PRIx16
, expected_max
, CMT
);
218 CHECK(TEST_MSG
, uint
, 32, 2, PRIx32
, expected_max
, CMT
);
219 CHECK(TEST_MSG
, uint
, 64, 1, PRIx64
, expected_max
, CMT
);
220 CHECK(TEST_MSG
, int, 8, 16, PRIx8
, expected_max
, CMT
);
221 CHECK(TEST_MSG
, int, 16, 8, PRIx16
, expected_max
, CMT
);
222 CHECK(TEST_MSG
, int, 32, 4, PRIx32
, expected_max
, CMT
);
223 CHECK(TEST_MSG
, int, 64, 2, PRIx64
, expected_max
, CMT
);
224 CHECK(TEST_MSG
, uint
, 8, 16, PRIx8
, expected_max
, CMT
);
225 CHECK(TEST_MSG
, uint
, 16, 8, PRIx16
, expected_max
, CMT
);
226 CHECK(TEST_MSG
, uint
, 32, 4, PRIx32
, expected_max
, CMT
);
227 CHECK(TEST_MSG
, uint
, 64, 2, PRIx64
, expected_max
, CMT
);