1 #include <arm_neon.h>
2 #include "arm-neon-ref.h"
3 #include "compute-ref-data.h"
4 
5 /* Expected results.  */
6 VECT_VAR_DECL(expected,int,8,8) [] = { 0xe0, 0xe2, 0xe4, 0xe6,
7 				       0xe8, 0xea, 0xec, 0xee };
8 VECT_VAR_DECL(expected,int,16,4) [] = { 0xff80, 0xff88, 0xff90, 0xff98 };
9 VECT_VAR_DECL(expected,int,32,2) [] = { 0xfffff000, 0xfffff100 };
10 VECT_VAR_DECL(expected,int,64,1) [] = { 0xffffffffffffff80 };
11 VECT_VAR_DECL(expected,uint,8,8) [] = { 0xe0, 0xe2, 0xe4, 0xe6,
12 					0xe8, 0xea, 0xec, 0xee };
13 VECT_VAR_DECL(expected,uint,16,4) [] = { 0xff80, 0xff88, 0xff90, 0xff98 };
14 VECT_VAR_DECL(expected,uint,32,2) [] = { 0xfffff000, 0xfffff100 };
15 VECT_VAR_DECL(expected,uint,64,1) [] = { 0xffffffffffffff80 };
16 VECT_VAR_DECL(expected,int,8,16) [] = { 0x0, 0x20, 0x40, 0x60,
17 					0x80, 0xa0, 0xc0, 0xe0,
18 					0x0, 0x20, 0x40, 0x60,
19 					0x80, 0xa0, 0xc0, 0xe0 };
20 VECT_VAR_DECL(expected,int,16,8) [] = { 0x0, 0x1000, 0x2000, 0x3000,
21 					0x4000, 0x5000, 0x6000, 0x7000 };
22 VECT_VAR_DECL(expected,int,32,4) [] = { 0x0, 0x40000000,
23 					0x80000000, 0xc0000000 };
24 VECT_VAR_DECL(expected,int,64,2) [] = { 0x0, 0x8000000000000000 };
25 VECT_VAR_DECL(expected,uint,8,16) [] = { 0x0, 0x20, 0x40, 0x60,
26 					 0x80, 0xa0, 0xc0, 0xe0,
27 					 0x0, 0x20, 0x40, 0x60,
28 					 0x80, 0xa0, 0xc0, 0xe0 };
29 VECT_VAR_DECL(expected,uint,16,8) [] = { 0x0, 0x1000, 0x2000, 0x3000,
30 					 0x4000, 0x5000, 0x6000, 0x7000 };
31 VECT_VAR_DECL(expected,uint,32,4) [] = { 0x0, 0x40000000,
32 					 0x80000000, 0xc0000000 };
33 VECT_VAR_DECL(expected,uint,64,2) [] = { 0x0, 0x8000000000000000 };
34 
35 /* Expected results with large shift amount.  */
36 VECT_VAR_DECL(expected_large_shift,int,8,8) [] = { 0x0, 0x0, 0x0, 0x0,
37 						   0x0, 0x0, 0x0, 0x0 };
38 VECT_VAR_DECL(expected_large_shift,int,16,4) [] = { 0x0, 0x0, 0x0, 0x0 };
39 VECT_VAR_DECL(expected_large_shift,int,32,2) [] = { 0x0, 0x0 };
40 VECT_VAR_DECL(expected_large_shift,int,64,1) [] = { 0x0 };
41 VECT_VAR_DECL(expected_large_shift,uint,8,8) [] = { 0x0, 0x0, 0x0, 0x0,
42 						    0x0, 0x0, 0x0, 0x0 };
43 VECT_VAR_DECL(expected_large_shift,uint,16,4) [] = { 0x0, 0x0, 0x0, 0x0 };
44 VECT_VAR_DECL(expected_large_shift,uint,32,2) [] = { 0x0, 0x0 };
45 VECT_VAR_DECL(expected_large_shift,uint,64,1) [] = { 0x0 };
46 VECT_VAR_DECL(expected_large_shift,int,8,16) [] = { 0x0, 0x0, 0x0, 0x0,
47 						    0x0, 0x0, 0x0, 0x0,
48 						    0x0, 0x0, 0x0, 0x0,
49 						    0x0, 0x0, 0x0, 0x0 };
50 VECT_VAR_DECL(expected_large_shift,int,16,8) [] = { 0x0, 0x0, 0x0, 0x0,
51 						    0x0, 0x0, 0x0, 0x0 };
52 VECT_VAR_DECL(expected_large_shift,int,32,4) [] = { 0x0, 0x0, 0x0, 0x0 };
53 VECT_VAR_DECL(expected_large_shift,int,64,2) [] = { 0x0, 0x0 };
54 VECT_VAR_DECL(expected_large_shift,uint,8,16) [] = { 0x0, 0x0, 0x0, 0x0,
55 						     0x0, 0x0, 0x0, 0x0,
56 						     0x0, 0x0, 0x0, 0x0,
57 						     0x0, 0x0, 0x0, 0x0 };
58 VECT_VAR_DECL(expected_large_shift,uint,16,8) [] = { 0x0, 0x0, 0x0, 0x0,
59 						     0x0, 0x0, 0x0, 0x0 };
60 VECT_VAR_DECL(expected_large_shift,uint,32,4) [] = { 0x0, 0x0, 0x0, 0x0 };
61 VECT_VAR_DECL(expected_large_shift,uint,64,2) [] = { 0x0, 0x0 };
62 
63 
64 /* Expected results with negative shift amount.  */
65 VECT_VAR_DECL(expected_negative_shift,int,8,8) [] = { 0xf8, 0xf8, 0xf9, 0xf9,
66 						      0xfa, 0xfa, 0xfb, 0xfb };
67 VECT_VAR_DECL(expected_negative_shift,int,16,4) [] = { 0xfff8, 0xfff8,
68 						       0xfff9, 0xfff9  };
69 VECT_VAR_DECL(expected_negative_shift,int,32,2) [] = { 0xfffffffc, 0xfffffffc };
70 VECT_VAR_DECL(expected_negative_shift,int,64,1) [] = { 0xffffffffffffffff };
71 VECT_VAR_DECL(expected_negative_shift,uint,8,8) [] = { 0x78, 0x78, 0x79, 0x79,
72 						       0x7a, 0x7a, 0x7b, 0x7b };
73 VECT_VAR_DECL(expected_negative_shift,uint,16,4) [] = { 0x7ff8, 0x7ff8,
74 							0x7ff9, 0x7ff9 };
75 VECT_VAR_DECL(expected_negative_shift,uint,32,2) [] = { 0x3ffffffc,
76 							0x3ffffffc };
77 VECT_VAR_DECL(expected_negative_shift,uint,64,1) [] = { 0xfffffffffffffff };
78 VECT_VAR_DECL(expected_negative_shift,int,8,16) [] = { 0xfc, 0xfc, 0xfc, 0xfc,
79 						       0xfd, 0xfd, 0xfd, 0xfd,
80 						       0xfe, 0xfe, 0xfe, 0xfe,
81 						       0xff, 0xff, 0xff, 0xff };
82 VECT_VAR_DECL(expected_negative_shift,int,16,8) [] = { 0xffff, 0xffff,
83 						       0xffff, 0xffff,
84 						       0xffff, 0xffff,
85 						       0xffff, 0xffff };
86 VECT_VAR_DECL(expected_negative_shift,int,32,4) [] = {  0xfffffffe, 0xfffffffe,
87 							0xfffffffe, 0xfffffffe };
88 VECT_VAR_DECL(expected_negative_shift,int,64,2) [] = { 0xffffffffffffffff,
89 						       0xffffffffffffffff };
90 VECT_VAR_DECL(expected_negative_shift,uint,8,16) [] = { 0x3c, 0x3c, 0x3c, 0x3c,
91 							0x3d, 0x3d, 0x3d, 0x3d,
92 							0x3e, 0x3e, 0x3e, 0x3e,
93 							0x3f, 0x3f, 0x3f, 0x3f };
94 VECT_VAR_DECL(expected_negative_shift,uint,16,8) [] = { 0x7ff, 0x7ff,
95 							0x7ff, 0x7ff,
96 							0x7ff, 0x7ff,
97 							0x7ff, 0x7ff };
98 VECT_VAR_DECL(expected_negative_shift,uint,32,4) [] = { 0x1ffffffe, 0x1ffffffe,
99 							0x1ffffffe, 0x1ffffffe };
100 VECT_VAR_DECL(expected_negative_shift,uint,64,2) [] = { 0x7ffffffffffffff,
101 							0x7ffffffffffffff };
102 
103 
104 #define INSN_NAME vshl
105 #define TEST_MSG "VSHL/VSHLQ"
106 
107 #define FNNAME1(NAME) exec_ ## NAME
108 #define FNNAME(NAME) FNNAME1(NAME)
109 
FNNAME(INSN_NAME)110 void FNNAME (INSN_NAME) (void)
111 {
112   /* Basic test: v3=vshl(v1,v2), then store the result.  */
113 #define TEST_VSHL(T3, Q, T1, T2, W, N)					\
114   VECT_VAR(vector_res, T1, W, N) =					\
115     vshl##Q##_##T2##W(VECT_VAR(vector, T1, W, N),			\
116 		      VECT_VAR(vector_shift, T3, W, N));		\
117   vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
118 
119   DECL_VARIABLE_ALL_VARIANTS(vector);
120   DECL_VARIABLE_ALL_VARIANTS(vector_res);
121 
122   DECL_VARIABLE_SIGNED_VARIANTS(vector_shift);
123 
124   clean_results ();
125 
126   /* Initialize input "vector" from "buffer".  */
127   TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer);
128 
129   /* Choose init value arbitrarily, will be used as shift amount.  */
130   VDUP(vector_shift, , int, s, 8, 8, 1);
131   VDUP(vector_shift, , int, s, 16, 4, 3);
132   VDUP(vector_shift, , int, s, 32, 2, 8);
133   VDUP(vector_shift, , int, s, 64, 1, 3);
134   VDUP(vector_shift, q, int, s, 8, 16, 5);
135   VDUP(vector_shift, q, int, s, 16, 8, 12);
136   VDUP(vector_shift, q, int, s, 32, 4, 30);
137   VDUP(vector_shift, q, int, s, 64, 2, 63);
138 
139   /* Execute the tests.  */
140   TEST_MACRO_ALL_VARIANTS_1_5(TEST_VSHL, int);
141 
142   CHECK(TEST_MSG, int, 8, 8, PRIx8, expected, "");
143   CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, "");
144   CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, "");
145   CHECK(TEST_MSG, int, 64, 1, PRIx64, expected, "");
146   CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected, "");
147   CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected, "");
148   CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected, "");
149   CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected, "");
150   CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, "");
151   CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, "");
152   CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, "");
153   CHECK(TEST_MSG, int, 64, 2, PRIx64, expected, "");
154   CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, "");
155   CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, "");
156   CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, "");
157   CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected, "");
158 
159 
160   /* Test large shift amount (larger or equal to the type width.  */
161   VDUP(vector_shift, , int, s, 8, 8, 8);
162   VDUP(vector_shift, , int, s, 16, 4, 16);
163   VDUP(vector_shift, , int, s, 32, 2, 32);
164   VDUP(vector_shift, , int, s, 64, 1, 64);
165   VDUP(vector_shift, q, int, s, 8, 16, 8);
166   VDUP(vector_shift, q, int, s, 16, 8, 17);
167   VDUP(vector_shift, q, int, s, 32, 4, 33);
168   VDUP(vector_shift, q, int, s, 64, 2, 65);
169 
170   /* Execute the tests.  */
171   TEST_MACRO_ALL_VARIANTS_1_5(TEST_VSHL, int);
172 
173 #define COMMENT1 "(large shift amount)"
174   CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_large_shift, COMMENT1);
175   CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_large_shift, COMMENT1);
176   CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_large_shift, COMMENT1);
177   CHECK(TEST_MSG, int, 64, 1, PRIx64, expected_large_shift, COMMENT1);
178   CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_large_shift, COMMENT1);
179   CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected_large_shift, COMMENT1);
180   CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_large_shift, COMMENT1);
181   CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected_large_shift, COMMENT1);
182   CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_large_shift, COMMENT1);
183   CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_large_shift, COMMENT1);
184   CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_large_shift, COMMENT1);
185   CHECK(TEST_MSG, int, 64, 2, PRIx64, expected_large_shift, COMMENT1);
186   CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_large_shift, COMMENT1);
187   CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_large_shift, COMMENT1);
188   CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_large_shift, COMMENT1);
189   CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected_large_shift, COMMENT1);
190 
191 
192   /* Test negative shift amount. */
193   VDUP(vector_shift, , int, s, 8, 8, -1);
194   VDUP(vector_shift, , int, s, 16, 4, -1);
195   VDUP(vector_shift, , int, s, 32, 2, -2);
196   VDUP(vector_shift, , int, s, 64, 1, -4);
197   VDUP(vector_shift, q, int, s, 8, 16, -2);
198   VDUP(vector_shift, q, int, s, 16, 8, -5);
199   VDUP(vector_shift, q, int, s, 32, 4, -3);
200   VDUP(vector_shift, q, int, s, 64, 2, -5);
201 
202   /* Execute the tests.  */
203   TEST_MACRO_ALL_VARIANTS_1_5(TEST_VSHL, int);
204 
205 #define COMMENT2 "(negative shift amount)"
206   CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_negative_shift, COMMENT2);
207   CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_negative_shift, COMMENT2);
208   CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_negative_shift, COMMENT2);
209   CHECK(TEST_MSG, int, 64, 1, PRIx64, expected_negative_shift, COMMENT2);
210   CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_negative_shift, COMMENT2);
211   CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected_negative_shift, COMMENT2);
212   CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_negative_shift, COMMENT2);
213   CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected_negative_shift, COMMENT2);
214   CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_negative_shift, COMMENT2);
215   CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_negative_shift, COMMENT2);
216   CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_negative_shift, COMMENT2);
217   CHECK(TEST_MSG, int, 64, 2, PRIx64, expected_negative_shift, COMMENT2);
218   CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_negative_shift, COMMENT2);
219   CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_negative_shift, COMMENT2);
220   CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_negative_shift, COMMENT2);
221   CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected_negative_shift, COMMENT2);
222 }
223 
main(void)224 int main (void)
225 {
226   FNNAME (INSN_NAME) ();
227 
228   return 0;
229 }
230