Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vqshrn_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. */
8 VECT_VAR_DECL(expected,int,8,16) [] = { 0xf0, 0xf1, 0xf2, 0xf3,
9 0xf4, 0xf5, 0xf6, 0xf7,
10 0xf8, 0xf8, 0xf9, 0xf9,
11 0xfa, 0xfa, 0xfb, 0xfb };
12 VECT_VAR_DECL(expected,int,16,8) [] = { 0xfff0, 0xfff1, 0xfff2, 0xfff3,
13 0xfff8, 0xfff8, 0xfff9, 0xfff9 };
14 VECT_VAR_DECL(expected,int,32,4) [] = { 0xfffffff0, 0xfffffff1,
15 0xfffffffc, 0xfffffffc };
16 VECT_VAR_DECL(expected,uint,8,16) [] = { 0xf0, 0xf1, 0xf2, 0xf3,
17 0xf4, 0xf5, 0xf6, 0xf7,
18 0xff, 0xff, 0xff, 0xff,
19 0xff, 0xff, 0xff, 0xff };
20 VECT_VAR_DECL(expected,uint,16,8) [] = { 0xfff0, 0xfff1, 0xfff2, 0xfff3,
21 0xffff, 0xffff, 0xffff, 0xffff };
22 VECT_VAR_DECL(expected,uint,32,4) [] = { 0xfffffff0, 0xfffffff1,
23 0xffffffff, 0xffffffff };
24
25 /* Expected results with max input value shifted by 3. */
26 VECT_VAR_DECL(expected_max_sh3,int,8,16) [] = { 0x7f, 0x7f, 0x7f, 0x7f,
27 0x7f, 0x7f, 0x7f, 0x7f,
28 0x7f, 0x7f, 0x7f, 0x7f,
29 0x7f, 0x7f, 0x7f, 0x7f };
30 VECT_VAR_DECL(expected_max_sh3,int,16,8) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff,
31 0x7fff, 0x7fff, 0x7fff, 0x7fff };
32 VECT_VAR_DECL(expected_max_sh3,int,32,4) [] = { 0x7fffffff, 0x7fffffff,
33 0x7fffffff, 0x7fffffff };
34 VECT_VAR_DECL(expected_max_sh3,uint,8,16) [] = { 0xff, 0xff, 0xff, 0xff,
35 0xff, 0xff, 0xff, 0xff,
36 0xff, 0xff, 0xff, 0xff,
37 0xff, 0xff, 0xff, 0xff };
38 VECT_VAR_DECL(expected_max_sh3,uint,16,8) [] = { 0xffff, 0xffff, 0xffff, 0xffff,
39 0xffff, 0xffff, 0xffff, 0xffff };
40 VECT_VAR_DECL(expected_max_sh3,uint,32,4) [] = { 0xffffffff, 0xffffffff,
41 0xffffffff, 0xffffffff };
42
43 /* Expected results with max input value shifted by type size. */
44 VECT_VAR_DECL(expected_max_shmax,int,8,16) [] = { 0x7f, 0x7f, 0x7f, 0x7f,
45 0x7f, 0x7f, 0x7f, 0x7f,
46 0x7f, 0x7f, 0x7f, 0x7f,
47 0x7f, 0x7f, 0x7f, 0x7f };
48 VECT_VAR_DECL(expected_max_shmax,int,16,8) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff,
49 0x7fff, 0x7fff, 0x7fff, 0x7fff };
50 VECT_VAR_DECL(expected_max_shmax,int,32,4) [] = { 0x7fffffff, 0x7fffffff,
51 0x7fffffff, 0x7fffffff };
52 VECT_VAR_DECL(expected_max_shmax,uint,8,16) [] = { 0xff, 0xff, 0xff, 0xff,
53 0xff, 0xff, 0xff, 0xff,
54 0xff, 0xff, 0xff, 0xff,
55 0xff, 0xff, 0xff, 0xff };
56 VECT_VAR_DECL(expected_max_shmax,uint,16,8) [] = { 0xffff, 0xffff, 0xffff, 0xffff,
57 0xffff, 0xffff, 0xffff, 0xffff };
58 VECT_VAR_DECL(expected_max_shmax,uint,32,4) [] = { 0xffffffff, 0xffffffff,
59 0xffffffff, 0xffffffff };
60
61 #define INSN vqshrn_high_n
62 #define TEST_MSG "VQSHRN_HIGH_N"
63
64 #define FNNAME1(NAME) void exec_ ## NAME (void)
65 #define FNNAME(NAME) FNNAME1(NAME)
66
67 FNNAME (INSN)
68 {
69 /* Basic test: y=vqshrn_high_n(x1,x2,v), then store the result. */
70 #define TEST_VQSHRN_HIGH_N2(INSN, T1, T2, W, W2, N, N2, V) \
71 VECT_VAR(vector_res, T1, W2, N2) = \
72 INSN##_##T2##W(VECT_VAR(vector1, T1, W2, N), \
73 VECT_VAR(vector2, T1, W, N), V); \
74 vst1q_##T2##W2(VECT_VAR(result, T1, W2, N2), \
75 VECT_VAR(vector_res, T1, W2, N2));
76
77 /* Two auxliary macros are necessary to expand INSN */
78 #define TEST_VQSHRN_HIGH_N1(INSN, T1, T2, W, W2, N, N2, V) \
79 TEST_VQSHRN_HIGH_N2(INSN, T1, T2, W, W2, N, N2, V)
80
81 #define TEST_VQSHRN_HIGH_N(T1, T2, W, W2, N, N2, V) \
82 TEST_VQSHRN_HIGH_N1(INSN, T1, T2, W, W2, N, N2, V)
83
84
85 DECL_VARIABLE(vector1, int, 8, 8);
86 DECL_VARIABLE(vector1, int, 16, 4);
87 DECL_VARIABLE(vector1, int, 32, 2);
88 DECL_VARIABLE(vector1, uint, 8, 8);
89 DECL_VARIABLE(vector1, uint, 16, 4);
90 DECL_VARIABLE(vector1, uint, 32, 2);
91
92 /* vector is twice as large as vector_res. */
93 DECL_VARIABLE(vector2, int, 16, 8);
94 DECL_VARIABLE(vector2, int, 32, 4);
95 DECL_VARIABLE(vector2, int, 64, 2);
96 DECL_VARIABLE(vector2, uint, 16, 8);
97 DECL_VARIABLE(vector2, uint, 32, 4);
98 DECL_VARIABLE(vector2, uint, 64, 2);
99
100 DECL_VARIABLE(vector_res, int, 8, 16);
101 DECL_VARIABLE(vector_res, int, 16, 8);
102 DECL_VARIABLE(vector_res, int, 32, 4);
103 DECL_VARIABLE(vector_res, uint, 8, 16);
104 DECL_VARIABLE(vector_res, uint, 16, 8);
105 DECL_VARIABLE(vector_res, uint, 32, 4);
106
107 clean_results ();
108
109 VLOAD(vector1, buffer, , int, s, 8, 8);
110 VLOAD(vector1, buffer, , int, s, 16, 4);
111 VLOAD(vector1, buffer, , int, s, 32, 2);
112 VLOAD(vector1, buffer, , uint, u, 8, 8);
113 VLOAD(vector1, buffer, , uint, u, 16, 4);
114 VLOAD(vector1, buffer, , uint, u, 32, 2);
115
116 VLOAD(vector2, buffer, q, int, s, 16, 8);
117 VLOAD(vector2, buffer, q, int, s, 32, 4);
118 VLOAD(vector2, buffer, q, int, s, 64, 2);
119 VLOAD(vector2, buffer, q, uint, u, 16, 8);
120 VLOAD(vector2, buffer, q, uint, u, 32, 4);
121 VLOAD(vector2, buffer, q, uint, u, 64, 2);
122
123 /* Choose shift amount arbitrarily. */
124 #define CMT ""
125 TEST_VQSHRN_HIGH_N(int, s, 16, 8, 8, 16, 1);
126 TEST_VQSHRN_HIGH_N(int, s, 32, 16, 4, 8, 1);
127 TEST_VQSHRN_HIGH_N(int, s, 64, 32, 2, 4, 2);
128 TEST_VQSHRN_HIGH_N(uint, u, 16, 8, 8, 16, 2);
129 TEST_VQSHRN_HIGH_N(uint, u, 32, 16, 4, 8, 3);
130 TEST_VQSHRN_HIGH_N(uint, u, 64, 32, 2, 4, 3);
131
132 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, CMT);
133 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, CMT);
134 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, CMT);
135 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, CMT);
136 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, CMT);
137 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, CMT);
138
139 /* Use max possible value as input. */
140 VDUP(vector1, , int, s, 8, 8, 0x7F);
141 VDUP(vector1, , int, s, 16, 4, 0x7FFF);
142 VDUP(vector1, , int, s, 32, 2, 0x7FFFFFFFLL);
143 VDUP(vector1, , uint, u, 8, 8, 0xFF);
144 VDUP(vector1, , uint, u, 16, 4, 0xFFFF);
145 VDUP(vector1, , uint, u, 32, 2, 0xFFFFFFFFULL);
146
147 VDUP(vector2, q, int, s, 16, 8, 0x7FFF);
148 VDUP(vector2, q, int, s, 32, 4, 0x7FFFFFFF);
149 VDUP(vector2, q, int, s, 64, 2, 0x7FFFFFFFFFFFFFFFLL);
150 VDUP(vector2, q, uint, u, 16, 8, 0xFFFF);
151 VDUP(vector2, q, uint, u, 32, 4, 0xFFFFFFFF);
152 VDUP(vector2, q, uint, u, 64, 2, 0xFFFFFFFFFFFFFFFFULL);
153
154 #undef CMT
155 #define CMT " (check saturation: shift by 3)"
156 TEST_VQSHRN_HIGH_N(int, s, 16, 8, 8, 16, 3);
157 TEST_VQSHRN_HIGH_N(int, s, 32, 16, 4, 8, 3);
158 TEST_VQSHRN_HIGH_N(int, s, 64, 32, 2, 4, 3);
159 TEST_VQSHRN_HIGH_N(uint, u, 16, 8, 8, 16, 3);
160 TEST_VQSHRN_HIGH_N(uint, u, 32, 16, 4, 8, 3);
161 TEST_VQSHRN_HIGH_N(uint, u, 64, 32, 2, 4, 3);
162
163 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_max_sh3, CMT);
164 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_max_sh3, CMT);
165 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_max_sh3, CMT);
166 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_max_sh3, CMT);
167 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_max_sh3, CMT);
168 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_max_sh3, CMT);
169
170
171 #undef CMT
172 #define CMT " (check saturation: shift by max)"
173 TEST_VQSHRN_HIGH_N(int, s, 16, 8, 8, 16, 8);
174 TEST_VQSHRN_HIGH_N(int, s, 32, 16, 4, 8, 16);
175 TEST_VQSHRN_HIGH_N(int, s, 64, 32, 2, 4, 32);
176 TEST_VQSHRN_HIGH_N(uint, u, 16, 8, 8, 16, 8);
177 TEST_VQSHRN_HIGH_N(uint, u, 32, 16, 4, 8, 16);
178 TEST_VQSHRN_HIGH_N(uint, u, 64, 32, 2, 4, 32);
179
180 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_max_shmax, CMT);
181 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_max_shmax, CMT);
182 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_max_shmax, CMT);
183 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_max_shmax, CMT);
184 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_max_shmax, CMT);
185 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_max_shmax, CMT);
186 }
187
188 int main (void)
189 {
190 exec_vqshrn_high_n ();
191 return 0;
192 }