2 #include "arm-neon-ref.h"
3 #include "compute-ref-data.h"
5 /* Expected results. */
6 VECT_VAR_DECL(expected,int,8,8) [] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
7 VECT_VAR_DECL(expected,int,16,4) [] = { 0x3, 0x3, 0x3, 0x3 };
8 VECT_VAR_DECL(expected,int,32,2) [] = { 0x11, 0x11 };
9 VECT_VAR_DECL(expected,int,64,1) [] = { 0x3333333333333333 };
10 VECT_VAR_DECL(expected,uint,8,8) [] = { 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2 };
11 VECT_VAR_DECL(expected,uint,16,4) [] = { 0x0, 0x0, 0x0, 0x0 };
12 VECT_VAR_DECL(expected,uint,32,2) [] = { 0x5, 0x5 };
13 VECT_VAR_DECL(expected,uint,64,1) [] = { 0x3333333333333333 };
14 VECT_VAR_DECL(expected,poly,8,8) [] = { 0x33, 0x33, 0x33, 0x33,
15 0x33, 0x33, 0x33, 0x33 };
16 VECT_VAR_DECL(expected,poly,16,4) [] = { 0x3333, 0x3333, 0x3333, 0x3333 };
17 VECT_VAR_DECL(expected,hfloat,32,2) [] = { 0x33333333, 0x33333333 };
18 VECT_VAR_DECL(expected,int,8,16) [] = { 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2,
19 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2 };
20 VECT_VAR_DECL(expected,int,16,8) [] = { 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3 };
21 VECT_VAR_DECL(expected,int,32,4) [] = { 0x3, 0x3, 0x3, 0x3 };
22 VECT_VAR_DECL(expected,int,64,2) [] = { 0x3333333333333333,
24 VECT_VAR_DECL(expected,uint,8,16) [] = { 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3,
25 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3 };
26 VECT_VAR_DECL(expected,uint,16,8) [] = { 0xd, 0xd, 0xd, 0xd,
28 VECT_VAR_DECL(expected,uint,32,4) [] = { 0x1f, 0x1f, 0x1f, 0x1f };
29 VECT_VAR_DECL(expected,uint,64,2) [] = { 0x3333333333333333,
31 VECT_VAR_DECL(expected,poly,8,16) [] = { 0x33, 0x33, 0x33, 0x33,
32 0x33, 0x33, 0x33, 0x33,
33 0x33, 0x33, 0x33, 0x33,
34 0x33, 0x33, 0x33, 0x33 };
35 VECT_VAR_DECL(expected,poly,16,8) [] = { 0x3333, 0x3333, 0x3333, 0x3333,
36 0x3333, 0x3333, 0x3333, 0x3333 };
37 VECT_VAR_DECL(expected,hfloat,32,4) [] = { 0x33333333, 0x33333333,
38 0x33333333, 0x33333333 };
41 /* Expected results with input=0. */
42 VECT_VAR_DECL(expected_with_0,int,8,8) [] = { 0x8, 0x8, 0x8, 0x8,
44 VECT_VAR_DECL(expected_with_0,int,16,4) [] = { 0x10, 0x10, 0x10, 0x10 };
45 VECT_VAR_DECL(expected_with_0,int,32,2) [] = { 0x20, 0x20 };
46 VECT_VAR_DECL(expected_with_0,int,64,1) [] = { 0x3333333333333333 };
47 VECT_VAR_DECL(expected_with_0,uint,8,8) [] = { 0x8, 0x8, 0x8, 0x8,
49 VECT_VAR_DECL(expected_with_0,uint,16,4) [] = { 0x10, 0x10, 0x10, 0x10 };
50 VECT_VAR_DECL(expected_with_0,uint,32,2) [] = { 0x20, 0x20 };
51 VECT_VAR_DECL(expected_with_0,uint,64,1) [] = { 0x3333333333333333 };
52 VECT_VAR_DECL(expected_with_0,poly,8,8) [] = { 0x33, 0x33, 0x33, 0x33,
53 0x33, 0x33, 0x33, 0x33 };
54 VECT_VAR_DECL(expected_with_0,poly,16,4) [] = { 0x3333, 0x3333, 0x3333, 0x3333 };
55 VECT_VAR_DECL(expected_with_0,hfloat,32,2) [] = { 0x33333333, 0x33333333 };
56 VECT_VAR_DECL(expected_with_0,int,8,16) [] = { 0x8, 0x8, 0x8, 0x8,
60 VECT_VAR_DECL(expected_with_0,int,16,8) [] = { 0x10, 0x10, 0x10, 0x10,
61 0x10, 0x10, 0x10, 0x10 };
62 VECT_VAR_DECL(expected_with_0,int,32,4) [] = { 0x20, 0x20, 0x20, 0x20 };
63 VECT_VAR_DECL(expected_with_0,int,64,2) [] = { 0x3333333333333333,
65 VECT_VAR_DECL(expected_with_0,uint,8,16) [] = { 0x8, 0x8, 0x8, 0x8,
69 VECT_VAR_DECL(expected_with_0,uint,16,8) [] = { 0x10, 0x10, 0x10, 0x10,
70 0x10, 0x10, 0x10, 0x10 };
71 VECT_VAR_DECL(expected_with_0,uint,32,4) [] = { 0x20, 0x20, 0x20, 0x20 };
72 VECT_VAR_DECL(expected_with_0,uint,64,2) [] = { 0x3333333333333333,
74 VECT_VAR_DECL(expected_with_0,poly,8,16) [] = { 0x33, 0x33, 0x33, 0x33,
75 0x33, 0x33, 0x33, 0x33,
76 0x33, 0x33, 0x33, 0x33,
77 0x33, 0x33, 0x33, 0x33 };
78 VECT_VAR_DECL(expected_with_0,poly,16,8) [] = { 0x3333, 0x3333, 0x3333, 0x3333,
79 0x3333, 0x3333, 0x3333, 0x3333 };
80 VECT_VAR_DECL(expected_with_0,hfloat,32,4) [] = { 0x33333333, 0x33333333,
81 0x33333333, 0x33333333 };
83 #define INSN_NAME vclz
84 #define TEST_MSG "VCLZ/VCLZQ"
86 #define FNNAME1(NAME) void exec_ ## NAME (void)
87 #define FNNAME(NAME) FNNAME1(NAME)
91 /* Basic test: y=vclz(x), then store the result. */
92 #define TEST_UNARY_OP1(INSN, Q, T1, T2, W, N) \
93 VECT_VAR(vector_res, T1, W, N) = \
94 INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N)); \
95 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
97 #define TEST_UNARY_OP(INSN, Q, T1, T2, W, N) \
98 TEST_UNARY_OP1(INSN, Q, T1, T2, W, N) \
100 /* No need for 64 bits variants */
101 DECL_VARIABLE(vector, int, 8, 8);
102 DECL_VARIABLE(vector, int, 16, 4);
103 DECL_VARIABLE(vector, int, 32, 2);
104 DECL_VARIABLE(vector, uint, 8, 8);
105 DECL_VARIABLE(vector, uint, 16, 4);
106 DECL_VARIABLE(vector, uint, 32, 2);
107 DECL_VARIABLE(vector, int, 8, 16);
108 DECL_VARIABLE(vector, int, 16, 8);
109 DECL_VARIABLE(vector, int, 32, 4);
110 DECL_VARIABLE(vector, uint, 8, 16);
111 DECL_VARIABLE(vector, uint, 16, 8);
112 DECL_VARIABLE(vector, uint, 32, 4);
114 DECL_VARIABLE(vector_res, int, 8, 8);
115 DECL_VARIABLE(vector_res, int, 16, 4);
116 DECL_VARIABLE(vector_res, int, 32, 2);
117 DECL_VARIABLE(vector_res, uint, 8, 8);
118 DECL_VARIABLE(vector_res, uint, 16, 4);
119 DECL_VARIABLE(vector_res, uint, 32, 2);
120 DECL_VARIABLE(vector_res, int, 8, 16);
121 DECL_VARIABLE(vector_res, int, 16, 8);
122 DECL_VARIABLE(vector_res, int, 32, 4);
123 DECL_VARIABLE(vector_res, uint, 8, 16);
124 DECL_VARIABLE(vector_res, uint, 16, 8);
125 DECL_VARIABLE(vector_res, uint, 32, 4);
129 /* Fill input vector with arbitrary values. */
130 VDUP(vector, , int, s, 8, 8, 0x84);
131 VDUP(vector, , int, s, 16, 4, 0x1234);
132 VDUP(vector, , int, s, 32, 2, 0x5678);
133 VDUP(vector, , uint, u, 8, 8, 0x34);
134 VDUP(vector, , uint, u, 16, 4, 0x8234);
135 VDUP(vector, , uint, u, 32, 2, 0x7654321);
136 VDUP(vector, q, int, s, 8, 16, 0x34);
137 VDUP(vector, q, int, s, 16, 8, 0x1234);
138 VDUP(vector, q, int, s, 32, 4, 0x12345678);
139 VDUP(vector, q, uint, u, 8, 16, 0x13);
140 VDUP(vector, q, uint, u, 16, 8, 0x4);
141 VDUP(vector, q, uint, u, 32, 4, 0x1);
143 /* Apply a unary operator named INSN_NAME. */
144 TEST_UNARY_OP(INSN_NAME, , int, s, 8, 8);
145 TEST_UNARY_OP(INSN_NAME, , int, s, 16, 4);
146 TEST_UNARY_OP(INSN_NAME, , int, s, 32, 2);
147 TEST_UNARY_OP(INSN_NAME, , uint, u, 8, 8);
148 TEST_UNARY_OP(INSN_NAME, , uint, u, 16, 4);
149 TEST_UNARY_OP(INSN_NAME, , uint, u, 32, 2);
150 TEST_UNARY_OP(INSN_NAME, q, int, s, 8, 16);
151 TEST_UNARY_OP(INSN_NAME, q, int, s, 16, 8);
152 TEST_UNARY_OP(INSN_NAME, q, int, s, 32, 4);
153 TEST_UNARY_OP(INSN_NAME, q, uint, u, 8, 16);
154 TEST_UNARY_OP(INSN_NAME, q, uint, u, 16, 8);
155 TEST_UNARY_OP(INSN_NAME, q, uint, u, 32, 4);
157 CHECK_RESULTS (TEST_MSG, "");
159 /* Test with zero as input. */
160 VDUP(vector, , int, s, 8, 8, 0);
161 VDUP(vector, , int, s, 16, 4, 0);
162 VDUP(vector, , int, s, 32, 2, 0);
163 VDUP(vector, , uint, u, 8, 8, 0);
164 VDUP(vector, , uint, u, 16, 4, 0);
165 VDUP(vector, , uint, u, 32, 2, 0);
166 VDUP(vector, q, int, s, 8, 16, 0);
167 VDUP(vector, q, int, s, 16, 8, 0);
168 VDUP(vector, q, int, s, 32, 4, 0);
169 VDUP(vector, q, uint, u, 8, 16, 0);
170 VDUP(vector, q, uint, u, 16, 8, 0);
171 VDUP(vector, q, uint, u, 32, 4, 0);
173 /* Apply a unary operator named INSN_NAME. */
174 TEST_UNARY_OP(INSN_NAME, , int, s, 8, 8);
175 TEST_UNARY_OP(INSN_NAME, , int, s, 16, 4);
176 TEST_UNARY_OP(INSN_NAME, , int, s, 32, 2);
177 TEST_UNARY_OP(INSN_NAME, , uint, u, 8, 8);
178 TEST_UNARY_OP(INSN_NAME, , uint, u, 16, 4);
179 TEST_UNARY_OP(INSN_NAME, , uint, u, 32, 2);
180 TEST_UNARY_OP(INSN_NAME, q, int, s, 8, 16);
181 TEST_UNARY_OP(INSN_NAME, q, int, s, 16, 8);
182 TEST_UNARY_OP(INSN_NAME, q, int, s, 32, 4);
183 TEST_UNARY_OP(INSN_NAME, q, uint, u, 8, 16);
184 TEST_UNARY_OP(INSN_NAME, q, uint, u, 16, 8);
185 TEST_UNARY_OP(INSN_NAME, q, uint, u, 32, 4);
187 CHECK_RESULTS_NAMED (TEST_MSG, expected_with_0, " (input=0)");