blob: 879061968de85e00b921161b41d359298ac0bf2f [file] [log] [blame]
Christophe Lyon073831a2011-01-24 17:37:40 +01001/*
2
3Copyright (c) 2009, 2010, 2011 STMicroelectronics
4Written by Christophe Lyon
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22THE SOFTWARE.
23
24*/
25
Christophe Lyon1775be02014-07-10 13:46:54 +020026#if defined(__arm__) || defined(__aarch64__)
Christophe Lyon073831a2011-01-24 17:37:40 +010027#include <arm_neon.h>
28#else
Christophe Lyon0dab5f72011-07-19 17:14:09 +020029#include "stm-arm-neon.h"
Christophe Lyon073831a2011-01-24 17:37:40 +010030#endif
31
32#include "stm-arm-neon-ref.h"
33
34#define TEST_MSG "VRSHL/VRSHLQ"
35void exec_vrshl (void)
36{
37 /* Basic test: v3=vrshl(v1,v2), then store the result. */
38#define TEST_VRSHL(T3, Q, T1, T2, W, N) \
39 VECT_VAR(vector_res, T1, W, N) = \
40 vrshl##Q##_##T2##W(VECT_VAR(vector, T1, W, N), \
41 VECT_VAR(vector_shift, T3, W, N)); \
42 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
43
44 /* With ARM RVCT, we need to declare variables before any executable
45 statement */
46 DECL_VARIABLE_ALL_VARIANTS(vector);
47 DECL_VARIABLE_ALL_VARIANTS(vector_res);
48
49 DECL_VARIABLE_SIGNED_VARIANTS(vector_shift);
50
51 clean_results ();
52
53 /* Fill input vector with 0, to check behavior on limits */
Christophe Lyonf2053672014-12-16 10:26:00 +010054 VDUP(vector, , int, s, 8, 8, 0);
55 VDUP(vector, , int, s, 16, 4, 0);
56 VDUP(vector, , int, s, 32, 2, 0);
57 VDUP(vector, , int, s, 64, 1, 0);
58 VDUP(vector, , uint, u, 8, 8, 0);
59 VDUP(vector, , uint, u, 16, 4, 0);
60 VDUP(vector, , uint, u, 32, 2, 0);
61 VDUP(vector, , uint, u, 64, 1, 0);
62 VDUP(vector, q, int, s, 8, 16, 0);
63 VDUP(vector, q, int, s, 16, 8, 0);
64 VDUP(vector, q, int, s, 32, 4, 0);
65 VDUP(vector, q, int, s, 64, 2, 0);
66 VDUP(vector, q, uint, u, 8, 16, 0);
67 VDUP(vector, q, uint, u, 16, 8, 0);
68 VDUP(vector, q, uint, u, 32, 4, 0);
69 VDUP(vector, q, uint, u, 64, 2, 0);
Christophe Lyon073831a2011-01-24 17:37:40 +010070
71 /* Choose init value arbitrarily, will be used as shift amount */
72 /* Use values equal to one-less-than the type width to check
73 behaviour on limits */
Christophe Lyonf2053672014-12-16 10:26:00 +010074 VDUP(vector_shift, , int, s, 8, 8, 7);
75 VDUP(vector_shift, , int, s, 16, 4, 15);
76 VDUP(vector_shift, , int, s, 32, 2, 31);
77 VDUP(vector_shift, , int, s, 64, 1, 63);
78 VDUP(vector_shift, q, int, s, 8, 16, 7);
79 VDUP(vector_shift, q, int, s, 16, 8, 15);
80 VDUP(vector_shift, q, int, s, 32, 4, 31);
81 VDUP(vector_shift, q, int, s, 64, 2, 63);
Christophe Lyon073831a2011-01-24 17:37:40 +010082
83 TEST_MACRO_ALL_VARIANTS_1_5(TEST_VRSHL, int);
84
85 dump_results_hex2 (TEST_MSG, " (with input = 0)");
86
87 /* Use negative shift amounts */
Christophe Lyonf2053672014-12-16 10:26:00 +010088 VDUP(vector_shift, , int, s, 8, 8, -1);
89 VDUP(vector_shift, , int, s, 16, 4, -2);
90 VDUP(vector_shift, , int, s, 32, 2, -3);
91 VDUP(vector_shift, , int, s, 64, 1, -4);
92 VDUP(vector_shift, q, int, s, 8, 16, -7);
93 VDUP(vector_shift, q, int, s, 16, 8, -11);
94 VDUP(vector_shift, q, int, s, 32, 4, -13);
95 VDUP(vector_shift, q, int, s, 64, 2, -20);
Christophe Lyon073831a2011-01-24 17:37:40 +010096
97 TEST_MACRO_ALL_VARIANTS_1_5(TEST_VRSHL, int);
98
99 dump_results_hex2 (TEST_MSG, " (input 0 and negative shift amount)");
100
101 /* Test again, with predefined input values */
Christophe Lyonf2053672014-12-16 10:26:00 +0100102 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer);
Christophe Lyon073831a2011-01-24 17:37:40 +0100103
104 /* Choose init value arbitrarily, will be used as shift amount */
Christophe Lyonf2053672014-12-16 10:26:00 +0100105 VDUP(vector_shift, , int, s, 8, 8, 1);
106 VDUP(vector_shift, , int, s, 16, 4, 3);
107 VDUP(vector_shift, , int, s, 32, 2, 8);
108 VDUP(vector_shift, , int, s, 64, 1, -3);
109 VDUP(vector_shift, q, int, s, 8, 16, 10);
110 VDUP(vector_shift, q, int, s, 16, 8, 12);
111 VDUP(vector_shift, q, int, s, 32, 4, 32);
112 VDUP(vector_shift, q, int, s, 64, 2, 63);
Christophe Lyon073831a2011-01-24 17:37:40 +0100113
114 TEST_MACRO_ALL_VARIANTS_1_5(TEST_VRSHL, int);
115
116 dump_results_hex (TEST_MSG);
117
118
119 /* Use negative shift amounts */
Christophe Lyonf2053672014-12-16 10:26:00 +0100120 VDUP(vector_shift, , int, s, 8, 8, -1);
121 VDUP(vector_shift, , int, s, 16, 4, -2);
122 VDUP(vector_shift, , int, s, 32, 2, -3);
123 VDUP(vector_shift, , int, s, 64, 1, -4);
124 VDUP(vector_shift, q, int, s, 8, 16, -7);
125 VDUP(vector_shift, q, int, s, 16, 8, -11);
126 VDUP(vector_shift, q, int, s, 32, 4, -13);
127 VDUP(vector_shift, q, int, s, 64, 2, -20);
Christophe Lyon073831a2011-01-24 17:37:40 +0100128
129 TEST_MACRO_ALL_VARIANTS_1_5(TEST_VRSHL, int);
130
131 dump_results_hex2 (TEST_MSG, " (negative shift amount)");
132
133 /* Fill input vector with max value, to check behavior on limits */
Christophe Lyonf2053672014-12-16 10:26:00 +0100134 VDUP(vector, , int, s, 8, 8, 0x7F);
135 VDUP(vector, , int, s, 16, 4, 0x7FFF);
136 VDUP(vector, , int, s, 32, 2, 0x7FFFFFFF);
137 VDUP(vector, , int, s, 64, 1, 0x7FFFFFFFFFFFFFFFLL);
138 VDUP(vector, , uint, u, 8, 8, 0xFF);
139 VDUP(vector, , uint, u, 16, 4, 0xFFFF);
140 VDUP(vector, , uint, u, 32, 2, 0xFFFFFFFF);
141 VDUP(vector, , uint, u, 64, 1, 0xFFFFFFFFFFFFFFFFULL);
142 VDUP(vector, q, int, s, 8, 16, 0x7F);
143 VDUP(vector, q, int, s, 16, 8, 0x7FFF);
144 VDUP(vector, q, int, s, 32, 4, 0x7FFFFFFF);
145 VDUP(vector, q, int, s, 64, 2, 0x7FFFFFFFFFFFFFFFLL);
146 VDUP(vector, q, uint, u, 8, 16, 0xFF);
147 VDUP(vector, q, uint, u, 16, 8, 0xFFFF);
148 VDUP(vector, q, uint, u, 32, 4, 0xFFFFFFFF);
149 VDUP(vector, q, uint, u, 64, 2, 0xFFFFFFFFFFFFFFFFULL);
Christophe Lyon073831a2011-01-24 17:37:40 +0100150
151 /* Use -1 shift amount to check overflow with round_const */
Christophe Lyonf2053672014-12-16 10:26:00 +0100152 VDUP(vector_shift, , int, s, 8, 8, -1);
153 VDUP(vector_shift, , int, s, 16, 4, -1);
154 VDUP(vector_shift, , int, s, 32, 2, -1);
155 VDUP(vector_shift, , int, s, 64, 1, -1);
156 VDUP(vector_shift, q, int, s, 8, 16, -1);
157 VDUP(vector_shift, q, int, s, 16, 8, -1);
158 VDUP(vector_shift, q, int, s, 32, 4, -1);
159 VDUP(vector_shift, q, int, s, 64, 2, -1);
Christophe Lyon073831a2011-01-24 17:37:40 +0100160
161 TEST_MACRO_ALL_VARIANTS_1_5(TEST_VRSHL, int);
162
163 dump_results_hex2 (TEST_MSG, " (checking round_const overflow: shift by -1)");
164
Christophe Lyon6ed6dc42011-02-08 18:34:27 +0100165 /* Use -3 shift amount to check overflow with round_const */
Christophe Lyonf2053672014-12-16 10:26:00 +0100166 VDUP(vector_shift, , int, s, 8, 8, -3);
167 VDUP(vector_shift, , int, s, 16, 4, -3);
168 VDUP(vector_shift, , int, s, 32, 2, -3);
169 VDUP(vector_shift, , int, s, 64, 1, -3);
170 VDUP(vector_shift, q, int, s, 8, 16, -3);
171 VDUP(vector_shift, q, int, s, 16, 8, -3);
172 VDUP(vector_shift, q, int, s, 32, 4, -3);
173 VDUP(vector_shift, q, int, s, 64, 2, -3);
Christophe Lyon073831a2011-01-24 17:37:40 +0100174
175 TEST_MACRO_ALL_VARIANTS_1_5(TEST_VRSHL, int);
176
177 dump_results_hex2 (TEST_MSG, " (checking round_const overflow: shift by -3)");
178
Christophe Lyon8f28f9a2011-02-08 18:34:04 +0100179 /* Use negative shift amount as large as input vector width */
Christophe Lyonf2053672014-12-16 10:26:00 +0100180 VDUP(vector_shift, , int, s, 8, 8, -8);
181 VDUP(vector_shift, , int, s, 16, 4, -16);
182 VDUP(vector_shift, , int, s, 32, 2, -32);
183 VDUP(vector_shift, , int, s, 64, 1, -64);
184 VDUP(vector_shift, q, int, s, 8, 16, -8);
185 VDUP(vector_shift, q, int, s, 16, 8, -16);
186 VDUP(vector_shift, q, int, s, 32, 4, -32);
187 VDUP(vector_shift, q, int, s, 64, 2, -64);
Christophe Lyon8f28f9a2011-02-08 18:34:04 +0100188
189 TEST_MACRO_ALL_VARIANTS_1_5(TEST_VRSHL, int);
190
191 dump_results_hex2 (TEST_MSG, " (checking negative shift amount as large as input vector width)");
192
Christophe Lyon073831a2011-01-24 17:37:40 +0100193 /* Test large shift amount */
Christophe Lyonf2053672014-12-16 10:26:00 +0100194 VDUP(vector_shift, , int, s, 8, 8, 10);
195 VDUP(vector_shift, , int, s, 16, 4, 20);
196 VDUP(vector_shift, , int, s, 32, 2, 33);
197 VDUP(vector_shift, , int, s, 64, 1, 65);
198 VDUP(vector_shift, q, int, s, 8, 16, 9);
199 VDUP(vector_shift, q, int, s, 16, 8, 16);
200 VDUP(vector_shift, q, int, s, 32, 4, 32);
201 VDUP(vector_shift, q, int, s, 64, 2, 64);
Christophe Lyon073831a2011-01-24 17:37:40 +0100202
203 TEST_MACRO_ALL_VARIANTS_1_5(TEST_VRSHL, int);
204
205 dump_results_hex2 (TEST_MSG, " (large shift amount)");
Christophe Lyon533adff2011-09-22 11:30:59 +0200206
207 /* Test large negative shift amount */
Christophe Lyonf2053672014-12-16 10:26:00 +0100208 VDUP(vector_shift, , int, s, 8, 8, -10);
209 VDUP(vector_shift, , int, s, 16, 4, -20);
210 VDUP(vector_shift, , int, s, 32, 2, -33);
211 VDUP(vector_shift, , int, s, 64, 1, -65);
212 VDUP(vector_shift, q, int, s, 8, 16, -9);
213 VDUP(vector_shift, q, int, s, 16, 8, -16);
214 VDUP(vector_shift, q, int, s, 32, 4, -32);
215 VDUP(vector_shift, q, int, s, 64, 2, -64);
Christophe Lyon533adff2011-09-22 11:30:59 +0200216
217 TEST_MACRO_ALL_VARIANTS_1_5(TEST_VRSHL, int);
218
219 dump_results_hex2 (TEST_MSG, " (large negative shift amount)");
Christophe Lyon073831a2011-01-24 17:37:40 +0100220}