Debian Codegraph @

third-party/simde/arm/neon/cltz.h

raw
1 /* SPDX-License-Identifier: MIT
2 *
3 * Permission is hereby granted, free of charge, to any person
4 * obtaining a copy of this software and associated documentation
5 * files (the "Software"), to deal in the Software without
6 * restriction, including without limitation the rights to use, copy,
7 * modify, merge, publish, distribute, sublicense, and/or sell copies
8 * of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be
12 * included in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 * Copyright:
24 * 2020 Evan Nemerson <[email protected]>
25 */
26
27 /* TODO: float fallbacks should use vclt(a, vdup_n(0.0)) */
28
29 #if !defined(SIMDE_ARM_NEON_CLTZ_H)
30 #define SIMDE_ARM_NEON_CLTZ_H
31
32 #include "types.h"
33 #include "shr_n.h"
34 #include "reinterpret.h"
35 #include "clt.h"
36 #include "dup_n.h"
37
38 HEDLEY_DIAGNOSTIC_PUSH
39 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
40 SIMDE_BEGIN_DECLS_
41
42 SIMDE_FUNCTION_ATTRIBUTES
43 uint64_t
44 simde_vcltzd_s64(int64_t a) {
45 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
46 return HEDLEY_STATIC_CAST(uint64_t, vcltzd_s64(a));
47 #else
48 return (a < 0) ? UINT64_MAX : 0;
49 #endif
50 }
51 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
52 #undef vcltzd_s64
53 #define vcltzd_s64(a) simde_vcltzd_s64(a)
54 #endif
55
56 SIMDE_FUNCTION_ATTRIBUTES
57 uint64_t
58 simde_vcltzd_f64(simde_float64_t a) {
59 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
60 return HEDLEY_STATIC_CAST(uint64_t, vcltzd_f64(a));
61 #else
62 return (a < SIMDE_FLOAT64_C(0.0)) ? UINT64_MAX : 0;
63 #endif
64 }
65 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
66 #undef vcltzd_f64
67 #define vcltzd_f64(a) simde_vcltzd_f64(a)
68 #endif
69
70 SIMDE_FUNCTION_ATTRIBUTES
71 uint32_t
72 simde_vcltzs_f32(simde_float32_t a) {
73 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
74 return HEDLEY_STATIC_CAST(uint32_t, vcltzs_f32(a));
75 #else
76 return (a < SIMDE_FLOAT32_C(0.0)) ? UINT32_MAX : 0;
77 #endif
78 }
79 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
80 #undef vcltzs_f32
81 #define vcltzs_f32(a) simde_vcltzs_f32(a)
82 #endif
83
84 SIMDE_FUNCTION_ATTRIBUTES
85 simde_uint32x2_t
86 simde_vcltz_f32(simde_float32x2_t a) {
87 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
88 return vcltz_f32(a);
89 #elif SIMDE_NATURAL_VECTOR_SIZE > 0
90 return simde_vclt_f32(a, simde_vdup_n_f32(SIMDE_FLOAT32_C(0.0)));
91 #else
92 simde_float32x2_private a_ = simde_float32x2_to_private(a);
93 simde_uint32x2_private r_;
94
95 #if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_100762)
96 r_.values = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values < SIMDE_FLOAT32_C(0.0));
97 #else
98 SIMDE_VECTORIZE
99 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
100 r_.values[i] = (a_.values[i] < SIMDE_FLOAT32_C(0.0)) ? ~UINT32_C(0) : UINT32_C(0);
101 }
102 #endif
103
104 return simde_uint32x2_from_private(r_);
105 #endif
106 }
107 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
108 #undef vcltz_f32
109 #define vcltz_f32(a) simde_vcltz_f32(a)
110 #endif
111
112 SIMDE_FUNCTION_ATTRIBUTES
113 simde_uint64x1_t
114 simde_vcltz_f64(simde_float64x1_t a) {
115 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
116 return vcltz_f64(a);
117 #elif SIMDE_NATURAL_VECTOR_SIZE > 0
118 return simde_vclt_f64(a, simde_vdup_n_f64(SIMDE_FLOAT64_C(0.0)));
119 #else
120 simde_float64x1_private a_ = simde_float64x1_to_private(a);
121 simde_uint64x1_private r_;
122
123 #if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR)
124 r_.values = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values < SIMDE_FLOAT64_C(0.0));
125 #else
126 SIMDE_VECTORIZE
127 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
128 r_.values[i] = (a_.values[i] < SIMDE_FLOAT64_C(0.0)) ? ~UINT64_C(0) : UINT64_C(0);
129 }
130 #endif
131
132 return simde_uint64x1_from_private(r_);
133 #endif
134 }
135 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
136 #undef vcltz_f64
137 #define vcltz_f64(a) simde_vcltz_f64(a)
138 #endif
139
140 SIMDE_FUNCTION_ATTRIBUTES
141 simde_uint8x8_t
142 simde_vcltz_s8(simde_int8x8_t a) {
143 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
144 return vcltz_s8(a);
145 #elif SIMDE_NATURAL_VECTOR_SIZE > 0
146 return simde_vclt_s8(a, simde_vdup_n_s8(0));
147 #else
148 return simde_vreinterpret_u8_s8(simde_vshr_n_s8(a, 7));
149 #endif
150 }
151 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
152 #undef vcltz_s8
153 #define vcltz_s8(a) simde_vcltz_s8(a)
154 #endif
155
156 SIMDE_FUNCTION_ATTRIBUTES
157 simde_uint16x4_t
158 simde_vcltz_s16(simde_int16x4_t a) {
159 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
160 return vcltz_s16(a);
161 #elif SIMDE_NATURAL_VECTOR_SIZE > 0
162 return simde_vclt_s16(a, simde_vdup_n_s16(0));
163 #else
164 return simde_vreinterpret_u16_s16(simde_vshr_n_s16(a, 15));
165 #endif
166 }
167 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
168 #undef vcltz_s16
169 #define vcltz_s16(a) simde_vcltz_s16(a)
170 #endif
171
172 SIMDE_FUNCTION_ATTRIBUTES
173 simde_uint32x2_t
174 simde_vcltz_s32(simde_int32x2_t a) {
175 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
176 return vcltz_s32(a);
177 #elif SIMDE_NATURAL_VECTOR_SIZE > 0
178 return simde_vclt_s32(a, simde_vdup_n_s32(0));
179 #else
180 return simde_vreinterpret_u32_s32(simde_vshr_n_s32(a, 31));
181 #endif
182 }
183 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
184 #undef vcltz_s32
185 #define vcltz_s32(a) simde_vcltz_s32(a)
186 #endif
187
188 SIMDE_FUNCTION_ATTRIBUTES
189 simde_uint64x1_t
190 simde_vcltz_s64(simde_int64x1_t a) {
191 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
192 return vcltz_s64(a);
193 #elif SIMDE_NATURAL_VECTOR_SIZE > 0
194 return simde_vclt_s64(a, simde_vdup_n_s64(0));
195 #else
196 return simde_vreinterpret_u64_s64(simde_vshr_n_s64(a, 63));
197 #endif
198 }
199 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
200 #undef vcltz_s64
201 #define vcltz_s64(a) simde_vcltz_s64(a)
202 #endif
203
204 SIMDE_FUNCTION_ATTRIBUTES
205 simde_uint32x4_t
206 simde_vcltzq_f32(simde_float32x4_t a) {
207 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
208 return vcltzq_f32(a);
209 #elif SIMDE_NATURAL_VECTOR_SIZE > 0
210 return simde_vcltq_f32(a, simde_vdupq_n_f32(SIMDE_FLOAT32_C(0.0)));
211 #else
212 simde_float32x4_private a_ = simde_float32x4_to_private(a);
213 simde_uint32x4_private r_;
214
215 #if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR)
216 r_.values = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values < SIMDE_FLOAT32_C(0.0));
217 #else
218 SIMDE_VECTORIZE
219 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
220 r_.values[i] = (a_.values[i] < SIMDE_FLOAT32_C(0.0)) ? ~UINT32_C(0) : UINT32_C(0);
221 }
222 #endif
223
224 return simde_uint32x4_from_private(r_);
225 #endif
226 }
227 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
228 #undef vcltzq_f32
229 #define vcltzq_f32(a) simde_vcltzq_f32(a)
230 #endif
231
232 SIMDE_FUNCTION_ATTRIBUTES
233 simde_uint64x2_t
234 simde_vcltzq_f64(simde_float64x2_t a) {
235 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
236 return vcltzq_f64(a);
237 #elif SIMDE_NATURAL_VECTOR_SIZE > 0
238 return simde_vcltq_f64(a, simde_vdupq_n_f64(SIMDE_FLOAT64_C(0.0)));
239 #else
240 simde_float64x2_private a_ = simde_float64x2_to_private(a);
241 simde_uint64x2_private r_;
242
243 #if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR)
244 r_.values = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values < SIMDE_FLOAT64_C(0.0));
245 #else
246 SIMDE_VECTORIZE
247 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
248 r_.values[i] = (a_.values[i] < SIMDE_FLOAT64_C(0.0)) ? ~UINT64_C(0) : UINT64_C(0);
249 }
250 #endif
251
252 return simde_uint64x2_from_private(r_);
253 #endif
254 }
255 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
256 #undef vcltzq_f64
257 #define vcltzq_f64(a) simde_vcltzq_f64(a)
258 #endif
259
260 SIMDE_FUNCTION_ATTRIBUTES
261 simde_uint8x16_t
262 simde_vcltzq_s8(simde_int8x16_t a) {
263 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
264 return vcltzq_s8(a);
265 #elif SIMDE_NATURAL_VECTOR_SIZE > 0
266 return simde_vcltq_s8(a, simde_vdupq_n_s8(0));
267 #else
268 return simde_vreinterpretq_u8_s8(simde_vshrq_n_s8(a, 7));
269 #endif
270 }
271 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
272 #undef vcltzq_s8
273 #define vcltzq_s8(a) simde_vcltzq_s8(a)
274 #endif
275
276 SIMDE_FUNCTION_ATTRIBUTES
277 simde_uint16x8_t
278 simde_vcltzq_s16(simde_int16x8_t a) {
279 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
280 return vcltzq_s16(a);
281 #elif SIMDE_NATURAL_VECTOR_SIZE > 0
282 return simde_vcltq_s16(a, simde_vdupq_n_s16(0));
283 #else
284 return simde_vreinterpretq_u16_s16(simde_vshrq_n_s16(a, 15));
285 #endif
286 }
287 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
288 #undef vcltzq_s16
289 #define vcltzq_s16(a) simde_vcltzq_s16(a)
290 #endif
291
292 SIMDE_FUNCTION_ATTRIBUTES
293 simde_uint32x4_t
294 simde_vcltzq_s32(simde_int32x4_t a) {
295 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
296 return vcltzq_s32(a);
297 #elif SIMDE_NATURAL_VECTOR_SIZE > 0
298 return simde_vcltq_s32(a, simde_vdupq_n_s32(0));
299 #else
300 return simde_vreinterpretq_u32_s32(simde_vshrq_n_s32(a, 31));
301 #endif
302 }
303 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
304 #undef vcltzq_s32
305 #define vcltzq_s32(a) simde_vcltzq_s32(a)
306 #endif
307
308 SIMDE_FUNCTION_ATTRIBUTES
309 simde_uint64x2_t
310 simde_vcltzq_s64(simde_int64x2_t a) {
311 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
312 return vcltzq_s64(a);
313 #elif SIMDE_NATURAL_VECTOR_SIZE > 0
314 return simde_vcltq_s64(a, simde_vdupq_n_s64(0));
315 #else
316 return simde_vreinterpretq_u64_s64(simde_vshrq_n_s64(a, 63));
317 #endif
318 }
319 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
320 #undef vcltzq_s64
321 #define vcltzq_s64(a) simde_vcltzq_s64(a)
322 #endif
323
324 SIMDE_END_DECLS_
325 HEDLEY_DIAGNOSTIC_POP
326
327 #endif /* !defined(SIMDE_ARM_NEON_CLTZ_H) */