Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vbsl.c

raw
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) [] = { 0xf2, 0xf2, 0xf2, 0xf2,
7 0xf6, 0xf6, 0xf6, 0xf6 };
8 VECT_VAR_DECL(expected,int,16,4) [] = { 0xfff0, 0xfff0, 0xfff2, 0xfff2 };
9 VECT_VAR_DECL(expected,int,32,2) [] = { 0xfffffff0, 0xfffffff0 };
10 VECT_VAR_DECL(expected,int,64,1) [] = { 0xfffffffffffffffd };
11 VECT_VAR_DECL(expected,uint,8,8) [] = { 0xf3, 0xf3, 0xf3, 0xf3,
12 0xf7, 0xf7, 0xf7, 0xf7 };
13 VECT_VAR_DECL(expected,uint,16,4) [] = { 0xfff0, 0xfff0, 0xfff2, 0xfff2 };
14 VECT_VAR_DECL(expected,uint,32,2) [] = { 0xfffffff0, 0xfffffff0 };
15 VECT_VAR_DECL(expected,uint,64,1) [] = { 0xfffffff1 };
16 VECT_VAR_DECL(expected,poly,8,8) [] = { 0xf3, 0xf3, 0xf3, 0xf3,
17 0xf7, 0xf7, 0xf7, 0xf7 };
18 VECT_VAR_DECL(expected,poly,16,4) [] = { 0xfff0, 0xfff0, 0xfff2, 0xfff2 };
19 #if MFLOAT8_SUPPORTED
20 VECT_VAR_DECL(expected,hmfloat,8,8) [] = { 0xfa, 0xfa, 0xfa, 0xfa,
21 0xfe, 0xfe, 0xfe, 0xfe };
22 #endif
23 #if defined (FP16_SUPPORTED)
24 VECT_VAR_DECL (expected, hfloat, 16, 4) [] = { 0xcc09, 0xcb89,
25 0xcb09, 0xca89 };
26 #endif
27 VECT_VAR_DECL(expected,hfloat,32,2) [] = { 0xc1800004, 0xc1700004 };
28 VECT_VAR_DECL(expected,int,8,16) [] = { 0xf2, 0xf2, 0xf2, 0xf2,
29 0xf6, 0xf6, 0xf6, 0xf6,
30 0xf2, 0xf2, 0xf2, 0xf2,
31 0xf6, 0xf6, 0xf6, 0xf6 };
32 VECT_VAR_DECL(expected,int,16,8) [] = { 0xfff0, 0xfff0, 0xfff2, 0xfff2,
33 0xfff4, 0xfff4, 0xfff6, 0xfff6 };
34 VECT_VAR_DECL(expected,int,32,4) [] = { 0xfffffff0, 0xfffffff0,
35 0xfffffff2, 0xfffffff2 };
36 VECT_VAR_DECL(expected,int,64,2) [] = { 0xfffffffffffffffd,
37 0xfffffffffffffffd };
38 VECT_VAR_DECL(expected,uint,8,16) [] = { 0xf3, 0xf3, 0xf3, 0xf3,
39 0xf7, 0xf7, 0xf7, 0xf7,
40 0xf3, 0xf3, 0xf3, 0xf3,
41 0xf7, 0xf7, 0xf7, 0xf7 };
42 VECT_VAR_DECL(expected,uint,16,8) [] = { 0xfff0, 0xfff0, 0xfff2, 0xfff2,
43 0xfff4, 0xfff4, 0xfff6, 0xfff6 };
44 VECT_VAR_DECL(expected,uint,32,4) [] = { 0xfffffff0, 0xfffffff0,
45 0xfffffff2, 0xfffffff2 };
46 VECT_VAR_DECL(expected,uint,64,2) [] = { 0xfffffff1,
47 0xfffffff1 };
48 VECT_VAR_DECL(expected,poly,8,16) [] = { 0xf3, 0xf3, 0xf3, 0xf3,
49 0xf7, 0xf7, 0xf7, 0xf7,
50 0xf3, 0xf3, 0xf3, 0xf3,
51 0xf7, 0xf7, 0xf7, 0xf7 };
52 VECT_VAR_DECL(expected,poly,16,8) [] = { 0xfff0, 0xfff0, 0xfff2, 0xfff2,
53 0xfff4, 0xfff4, 0xfff6, 0xfff6 };
54 #if MFLOAT8_SUPPORTED
55 VECT_VAR_DECL(expected,hmfloat,8,16) [] = { 0xf1, 0xf1, 0xf1, 0xf1,
56 0xf5, 0xf5, 0xf5, 0xf5,
57 0xf1, 0xf1, 0xf1, 0xf1,
58 0xf5, 0xf5, 0xf5, 0xf5 };
59 #endif
60 #if defined (FP16_SUPPORTED)
61 VECT_VAR_DECL (expected, hfloat, 16, 8) [] = { 0xcc09, 0xcb89,
62 0xcb09, 0xca89,
63 0xca09, 0xc989,
64 0xc909, 0xc889 };
65 #endif
66 VECT_VAR_DECL(expected,hfloat,32,4) [] = { 0xc1800001, 0xc1700001,
67 0xc1600001, 0xc1500001 };
68
69 #define TEST_MSG "VBSL/VBSLQ"
70 void exec_vbsl (void)
71 {
72 /* Basic test: y=vbsl(unsigned_vec,x1,x2), then store the result. */
73 #define TEST_VBSL(T3, Q, T1, T2, W, N) \
74 VECT_VAR(vector_res, T1, W, N) = \
75 vbsl##Q##_##T2##W(VECT_VAR(vector_first, T3, W, N), \
76 VECT_VAR(vector, T1, W, N), \
77 VECT_VAR(vector2, T1, W, N)); \
78 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
79
80 DECL_VARIABLE_ALL_VARIANTS(vector);
81 DECL_VARIABLE_ALL_VARIANTS(vector2);
82 DECL_VARIABLE_ALL_VARIANTS(vector_res);
83
84 DECL_VARIABLE_UNSIGNED_VARIANTS(vector_first);
85
86 clean_results ();
87
88 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer);
89 #if MFLOAT8_SUPPORTED
90 VLOAD(vector, buffer, , mfloat, mf, 8, 8);
91 VLOAD(vector, buffer, q, mfloat, mf, 8, 16);
92 #endif
93 #if defined (FP16_SUPPORTED)
94 VLOAD(vector, buffer, , float, f, 16, 4);
95 VLOAD(vector, buffer, q, float, f, 16, 8);
96 #endif
97 VLOAD(vector, buffer, , float, f, 32, 2);
98 VLOAD(vector, buffer, q, float, f, 32, 4);
99
100 /* Choose init value arbitrarily, will be used for vector
101 comparison. As we want different values for each type variant, we
102 can't use generic initialization macros. */
103 VDUP(vector2, , int, s, 8, 8, -10);
104 VDUP(vector2, , int, s, 16, 4, -14);
105 VDUP(vector2, , int, s, 32, 2, -30);
106 VDUP(vector2, , int, s, 64, 1, -33);
107 VDUP(vector2, , uint, u, 8, 8, 0xF3);
108 VDUP(vector2, , uint, u, 16, 4, 0xFFF2);
109 VDUP(vector2, , uint, u, 32, 2, 0xFFFFFFF0);
110 VDUP(vector2, , uint, u, 64, 1, 0xFFFFFFF3);
111 MFLOAT8_ONLY(VDUP(vector2, , mfloat, mf, 8, 8, MFLOAT8(0xca));)
112 #if defined (FP16_SUPPORTED)
113 VDUP(vector2, , float, f, 16, 4, -2.4f); /* -2.4f is 0xC0CD. */
114 #endif
115 VDUP(vector2, , float, f, 32, 2, -30.3f);
116 VDUP(vector2, , poly, p, 8, 8, 0xF3);
117 VDUP(vector2, , poly, p, 16, 4, 0xFFF2);
118
119 VDUP(vector2, q, int, s, 8, 16, -10);
120 VDUP(vector2, q, int, s, 16, 8, -14);
121 VDUP(vector2, q, int, s, 32, 4, -30);
122 VDUP(vector2, q, int, s, 64, 2, -33);
123 VDUP(vector2, q, uint, u, 8, 16, 0xF3);
124 VDUP(vector2, q, uint, u, 16, 8, 0xFFF2);
125 VDUP(vector2, q, uint, u, 32, 4, 0xFFFFFFF0);
126 VDUP(vector2, q, uint, u, 64, 2, 0xFFFFFFF3);
127 VDUP(vector2, q, poly, p, 8, 16, 0xF3);
128 VDUP(vector2, q, poly, p, 16, 8, 0xFFF2);
129 MFLOAT8_ONLY(VDUP(vector2, q, mfloat, mf, 8, 16, MFLOAT8(0x55));)
130 #if defined (FP16_SUPPORTED)
131 VDUP(vector2, q, float, f, 16, 8, -2.4f);
132 #endif
133 VDUP(vector2, q, float, f, 32, 4, -30.4f);
134
135 VDUP(vector_first, , uint, u, 8, 8, 0xF4);
136 VDUP(vector_first, , uint, u, 16, 4, 0xFFF6);
137 VDUP(vector_first, , uint, u, 32, 2, 0xFFFFFFF2);
138 VDUP(vector_first, , uint, u, 64, 1, 0xFFFFFFF2);
139 VDUP(vector_first, q, uint, u, 8, 16, 0xF4);
140 VDUP(vector_first, q, uint, u, 16, 8, 0xFFF6);
141 VDUP(vector_first, q, uint, u, 32, 4, 0xFFFFFFF2);
142 VDUP(vector_first, q, uint, u, 64, 2, 0xFFFFFFF2);
143
144 /* Execute the tests. */
145 TEST_MACRO_ALL_VARIANTS_1_5(TEST_VBSL, uint);
146 TEST_VBSL(uint, , poly, p, 8, 8);
147 TEST_VBSL(uint, , poly, p, 16, 4);
148 TEST_VBSL(uint, q, poly, p, 8, 16);
149 TEST_VBSL(uint, q, poly, p, 16, 8);
150 #if MFLOAT8_SUPPORTED
151 TEST_VBSL(uint, , mfloat, mf, 8, 8);
152 TEST_VBSL(uint, q, mfloat, mf, 8, 16);
153 #endif
154 #if defined (FP16_SUPPORTED)
155 TEST_VBSL(uint, , float, f, 16, 4);
156 TEST_VBSL(uint, q, float, f, 16, 8);
157 #endif
158 TEST_VBSL(uint, , float, f, 32, 2);
159 TEST_VBSL(uint, q, float, f, 32, 4);
160
161 #if defined (FP16_SUPPORTED)
162 CHECK_RESULTS (TEST_MSG, "");
163 #else
164 CHECK_RESULTS_NO_FP16 (TEST_MSG, "");
165 #endif
166 }
167
168 int main (void)
169 {
170 exec_vbsl ();
171 return 0;
172 }