Debian Codegraph @

third-party/simde/arm/neon/bsl.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 * 2020 Sean Maher <[email protected]> (Copyright owned by Google, LLC)
26 */
27
28 #if !defined(SIMDE_ARM_NEON_BSL_H)
29 #define SIMDE_ARM_NEON_BSL_H
30
31 #include "types.h"
32 #include "reinterpret.h"
33 #include "and.h"
34 #include "eor.h"
35
36 HEDLEY_DIAGNOSTIC_PUSH
37 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
38 SIMDE_BEGIN_DECLS_
39
40 SIMDE_FUNCTION_ATTRIBUTES
41 simde_float16x4_t
42 simde_vbsl_f16(simde_uint16x4_t a, simde_float16x4_t b, simde_float16x4_t c) {
43 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE) && defined(SIMDE_ARM_NEON_FP16)
44 return vbsl_f16(a, b, c);
45 #else
46 simde_uint16x4_private
47 r_,
48 a_ = simde_uint16x4_to_private(a),
49 b_ = simde_uint16x4_to_private(simde_vreinterpret_u16_f16(b)),
50 c_ = simde_uint16x4_to_private(simde_vreinterpret_u16_f16(c));
51
52 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
53 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
54 #else
55 SIMDE_VECTORIZE
56 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
57 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
58 }
59 #endif
60
61 return simde_vreinterpret_f16_u16(simde_uint16x4_from_private(r_));
62 #endif
63 }
64 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
65 #undef vbsl_f16
66 #define vbsl_f16(a, b, c) simde_vbsl_f16((a), (b), (c))
67 #endif
68
69 SIMDE_FUNCTION_ATTRIBUTES
70 simde_float32x2_t
71 simde_vbsl_f32(simde_uint32x2_t a, simde_float32x2_t b, simde_float32x2_t c) {
72 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
73 return vbsl_f32(a, b, c);
74 #else
75 simde_uint32x2_private
76 r_,
77 a_ = simde_uint32x2_to_private(a),
78 b_ = simde_uint32x2_to_private(simde_vreinterpret_u32_f32(b)),
79 c_ = simde_uint32x2_to_private(simde_vreinterpret_u32_f32(c));
80
81 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
82 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
83 #else
84 SIMDE_VECTORIZE
85 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
86 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
87 }
88 #endif
89
90 return simde_vreinterpret_f32_u32(simde_uint32x2_from_private(r_));
91 #endif
92 }
93 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
94 #undef vbsl_f32
95 #define vbsl_f32(a, b, c) simde_vbsl_f32((a), (b), (c))
96 #endif
97
98 SIMDE_FUNCTION_ATTRIBUTES
99 simde_float64x1_t
100 simde_vbsl_f64(simde_uint64x1_t a, simde_float64x1_t b, simde_float64x1_t c) {
101 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
102 return vbsl_f64(a, b, c);
103 #else
104 simde_uint64x1_private
105 r_,
106 a_ = simde_uint64x1_to_private(a),
107 b_ = simde_uint64x1_to_private(simde_vreinterpret_u64_f64(b)),
108 c_ = simde_uint64x1_to_private(simde_vreinterpret_u64_f64(c));
109
110 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
111 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
112 #else
113 SIMDE_VECTORIZE
114 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
115 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
116 }
117 #endif
118
119 return simde_vreinterpret_f64_u64(simde_uint64x1_from_private(r_));
120 #endif
121 }
122 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
123 #undef vbsl_f64
124 #define vbsl_f64(a, b, c) simde_vbsl_f64((a), (b), (c))
125 #endif
126
127 SIMDE_FUNCTION_ATTRIBUTES
128 simde_int8x8_t
129 simde_vbsl_s8(simde_uint8x8_t a, simde_int8x8_t b, simde_int8x8_t c) {
130 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
131 return vbsl_s8(a, b, c);
132 #else
133 simde_uint8x8_private
134 r_,
135 a_ = simde_uint8x8_to_private(a),
136 b_ = simde_uint8x8_to_private(simde_vreinterpret_u8_s8(b)),
137 c_ = simde_uint8x8_to_private(simde_vreinterpret_u8_s8(c));
138
139 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
140 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
141 #else
142 SIMDE_VECTORIZE
143 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
144 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
145 }
146 #endif
147
148 return simde_vreinterpret_s8_u8(simde_uint8x8_from_private(r_));
149 #endif
150 }
151 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
152 #undef vbsl_s8
153 #define vbsl_s8(a, b, c) simde_vbsl_s8((a), (b), (c))
154 #endif
155
156 SIMDE_FUNCTION_ATTRIBUTES
157 simde_int16x4_t
158 simde_vbsl_s16(simde_uint16x4_t a, simde_int16x4_t b, simde_int16x4_t c) {
159 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
160 return vbsl_s16(a, b, c);
161 #else
162 simde_uint16x4_private
163 r_,
164 a_ = simde_uint16x4_to_private(a),
165 b_ = simde_uint16x4_to_private(simde_vreinterpret_u16_s16(b)),
166 c_ = simde_uint16x4_to_private(simde_vreinterpret_u16_s16(c));
167
168 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
169 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
170 #else
171 SIMDE_VECTORIZE
172 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
173 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
174 }
175 #endif
176
177 return simde_vreinterpret_s16_u16(simde_uint16x4_from_private(r_));
178 #endif
179 }
180 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
181 #undef vbsl_s16
182 #define vbsl_s16(a, b, c) simde_vbsl_s16((a), (b), (c))
183 #endif
184
185 SIMDE_FUNCTION_ATTRIBUTES
186 simde_int32x2_t
187 simde_vbsl_s32(simde_uint32x2_t a, simde_int32x2_t b, simde_int32x2_t c) {
188 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
189 return vbsl_s32(a, b, c);
190 #else
191 simde_uint32x2_private
192 r_,
193 a_ = simde_uint32x2_to_private(a),
194 b_ = simde_uint32x2_to_private(simde_vreinterpret_u32_s32(b)),
195 c_ = simde_uint32x2_to_private(simde_vreinterpret_u32_s32(c));
196
197 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
198 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
199 #else
200 SIMDE_VECTORIZE
201 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
202 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
203 }
204 #endif
205
206 return simde_vreinterpret_s32_u32(simde_uint32x2_from_private(r_));
207 #endif
208 }
209 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
210 #undef vbsl_s32
211 #define vbsl_s32(a, b, c) simde_vbsl_s32((a), (b), (c))
212 #endif
213
214 SIMDE_FUNCTION_ATTRIBUTES
215 simde_int64x1_t
216 simde_vbsl_s64(simde_uint64x1_t a, simde_int64x1_t b, simde_int64x1_t c) {
217 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
218 return vbsl_s64(a, b, c);
219 #else
220 simde_uint64x1_private
221 r_,
222 a_ = simde_uint64x1_to_private(a),
223 b_ = simde_uint64x1_to_private(simde_vreinterpret_u64_s64(b)),
224 c_ = simde_uint64x1_to_private(simde_vreinterpret_u64_s64(c));
225
226 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
227 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
228 #else
229 SIMDE_VECTORIZE
230 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
231 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
232 }
233 #endif
234
235 return simde_vreinterpret_s64_u64(simde_uint64x1_from_private(r_));
236 #endif
237 }
238 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
239 #undef vbsl_s64
240 #define vbsl_s64(a, b, c) simde_vbsl_s64((a), (b), (c))
241 #endif
242
243 SIMDE_FUNCTION_ATTRIBUTES
244 simde_uint8x8_t
245 simde_vbsl_u8(simde_uint8x8_t a, simde_uint8x8_t b, simde_uint8x8_t c) {
246 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
247 return vbsl_u8(a, b, c);
248 #else
249 simde_uint8x8_private
250 r_,
251 a_ = simde_uint8x8_to_private(a),
252 b_ = simde_uint8x8_to_private(b),
253 c_ = simde_uint8x8_to_private(c);
254
255 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
256 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
257 #else
258 SIMDE_VECTORIZE
259 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
260 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
261 }
262 #endif
263
264 return simde_uint8x8_from_private(r_);
265 #endif
266 }
267 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
268 #undef vbsl_u8
269 #define vbsl_u8(a, b, c) simde_vbsl_u8((a), (b), (c))
270 #endif
271
272 SIMDE_FUNCTION_ATTRIBUTES
273 simde_uint16x4_t
274 simde_vbsl_u16(simde_uint16x4_t a, simde_uint16x4_t b, simde_uint16x4_t c) {
275 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
276 return vbsl_u16(a, b, c);
277 #else
278 simde_uint16x4_private
279 r_,
280 a_ = simde_uint16x4_to_private(a),
281 b_ = simde_uint16x4_to_private(b),
282 c_ = simde_uint16x4_to_private(c);
283
284 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
285 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
286 #else
287 SIMDE_VECTORIZE
288 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
289 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
290 }
291 #endif
292
293 return simde_uint16x4_from_private(r_);
294 #endif
295 }
296 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
297 #undef vbsl_u16
298 #define vbsl_u16(a, b, c) simde_vbsl_u16((a), (b), (c))
299 #endif
300
301 SIMDE_FUNCTION_ATTRIBUTES
302 simde_uint32x2_t
303 simde_vbsl_u32(simde_uint32x2_t a, simde_uint32x2_t b, simde_uint32x2_t c) {
304 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
305 return vbsl_u32(a, b, c);
306 #else
307 simde_uint32x2_private
308 r_,
309 a_ = simde_uint32x2_to_private(a),
310 b_ = simde_uint32x2_to_private(b),
311 c_ = simde_uint32x2_to_private(c);
312
313 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
314 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
315 #else
316 SIMDE_VECTORIZE
317 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
318 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
319 }
320 #endif
321
322 return simde_uint32x2_from_private(r_);
323 #endif
324 }
325 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
326 #undef vbsl_u32
327 #define vbsl_u32(a, b, c) simde_vbsl_u32((a), (b), (c))
328 #endif
329
330 SIMDE_FUNCTION_ATTRIBUTES
331 simde_uint64x1_t
332 simde_vbsl_u64(simde_uint64x1_t a, simde_uint64x1_t b, simde_uint64x1_t c) {
333 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
334 return vbsl_u64(a, b, c);
335 #else
336 simde_uint64x1_private
337 r_,
338 a_ = simde_uint64x1_to_private(a),
339 b_ = simde_uint64x1_to_private(b),
340 c_ = simde_uint64x1_to_private(c);
341
342 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
343 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
344 #else
345 SIMDE_VECTORIZE
346 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
347 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
348 }
349 #endif
350
351 return simde_uint64x1_from_private(r_);
352 #endif
353 }
354 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
355 #undef vbsl_u64
356 #define vbsl_u64(a, b, c) simde_vbsl_u64((a), (b), (c))
357 #endif
358
359 SIMDE_FUNCTION_ATTRIBUTES
360 simde_float16x8_t
361 simde_vbslq_f16(simde_uint16x8_t a, simde_float16x8_t b, simde_float16x8_t c) {
362 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE) && defined(SIMDE_ARM_NEON_FP16)
363 return vbslq_f16(a, b, c);
364 #else
365 simde_uint16x8_private
366 r_,
367 a_ = simde_uint16x8_to_private(a),
368 b_ = simde_uint16x8_to_private(simde_vreinterpretq_u16_f16(b)),
369 c_ = simde_uint16x8_to_private(simde_vreinterpretq_u16_f16(c));
370
371 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
372 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
373 #else
374 SIMDE_VECTORIZE
375 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
376 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
377 }
378 #endif
379
380 return simde_vreinterpretq_f16_u16(simde_uint16x8_from_private(r_));
381 #endif
382 }
383 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
384 #undef vbslq_f16
385 #define vbslq_f16(a, b, c) simde_vbslq_f16((a), (b), (c))
386 #endif
387
388 SIMDE_FUNCTION_ATTRIBUTES
389 simde_float32x4_t
390 simde_vbslq_f32(simde_uint32x4_t a, simde_float32x4_t b, simde_float32x4_t c) {
391 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
392 return vbslq_f32(a, b, c);
393 #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) || defined(SIMDE_ZARCH_ZVECTOR_14_NATIVE)
394 return vec_sel(c, b, a);
395 #else
396 simde_uint32x4_private
397 r_,
398 a_ = simde_uint32x4_to_private(a),
399 b_ = simde_uint32x4_to_private(simde_vreinterpretq_u32_f32(b)),
400 c_ = simde_uint32x4_to_private(simde_vreinterpretq_u32_f32(c));
401
402 #if defined(SIMDE_WASM_SIMD128_NATIVE)
403 r_.v128 = wasm_v128_bitselect(b_.v128, c_.v128, a_.v128);
404 #elif defined(SIMDE_X86_AVX512VL_NATIVE)
405 r_.m128i = _mm_ternarylogic_epi32(a_.m128i, b_.m128i, c_.m128i, 0xca);
406 #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
407 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
408 #else
409 SIMDE_VECTORIZE
410 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
411 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
412 }
413 #endif
414
415 return simde_vreinterpretq_f32_u32(simde_uint32x4_from_private(r_));
416 #endif
417 }
418 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
419 #undef vbslq_f32
420 #define vbslq_f32(a, b, c) simde_vbslq_f32((a), (b), (c))
421 #endif
422
423
424 SIMDE_FUNCTION_ATTRIBUTES
425 simde_float64x2_t
426 simde_vbslq_f64(simde_uint64x2_t a, simde_float64x2_t b, simde_float64x2_t c) {
427 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
428 return vbslq_f64(a, b, c);
429 #elif defined(SIMDE_POWER_ALTIVEC_P8_NATIVE) || defined(SIMDE_ZARCH_ZVECTOR_13_NATIVE)
430 return vec_sel(c, b, a);
431 #else
432 simde_uint64x2_private
433 r_,
434 a_ = simde_uint64x2_to_private(a),
435 b_ = simde_uint64x2_to_private(simde_vreinterpretq_u64_f64(b)),
436 c_ = simde_uint64x2_to_private(simde_vreinterpretq_u64_f64(c));
437
438 #if defined(SIMDE_WASM_SIMD128_NATIVE)
439 r_.v128 = wasm_v128_bitselect(b_.v128, c_.v128, a_.v128);
440 #elif defined(SIMDE_X86_AVX512VL_NATIVE)
441 r_.m128i = _mm_ternarylogic_epi64(a_.m128i, b_.m128i, c_.m128i, 0xca);
442 #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
443 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
444 #else
445 SIMDE_VECTORIZE
446 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
447 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
448 }
449 #endif
450
451 return simde_vreinterpretq_f64_u64(simde_uint64x2_from_private(r_));
452 #endif
453 }
454 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
455 #undef vbslq_f64
456 #define vbslq_f64(a, b, c) simde_vbslq_f64((a), (b), (c))
457 #endif
458
459 SIMDE_FUNCTION_ATTRIBUTES
460 simde_int8x16_t
461 simde_vbslq_s8(simde_uint8x16_t a, simde_int8x16_t b, simde_int8x16_t c) {
462 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
463 return vbslq_s8(a, b, c);
464 #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) || defined(SIMDE_ZARCH_ZVECTOR_13_NATIVE)
465 return vec_sel(c, b, a);
466 #else
467 simde_uint8x16_private
468 r_,
469 a_ = simde_uint8x16_to_private(a),
470 b_ = simde_uint8x16_to_private(simde_vreinterpretq_u8_s8(b)),
471 c_ = simde_uint8x16_to_private(simde_vreinterpretq_u8_s8(c));
472
473 #if defined(SIMDE_WASM_SIMD128_NATIVE)
474 r_.v128 = wasm_v128_bitselect(b_.v128, c_.v128, a_.v128);
475 #elif defined(SIMDE_X86_AVX512VL_NATIVE)
476 r_.m128i = _mm_ternarylogic_epi32(a_.m128i, b_.m128i, c_.m128i, 0xca);
477 #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
478 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
479 #else
480 SIMDE_VECTORIZE
481 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
482 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
483 }
484 #endif
485
486 return simde_vreinterpretq_s8_u8(simde_uint8x16_from_private(r_));
487 #endif
488 }
489 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
490 #undef vbslq_s8
491 #define vbslq_s8(a, b, c) simde_vbslq_s8((a), (b), (c))
492 #endif
493
494 SIMDE_FUNCTION_ATTRIBUTES
495 simde_int16x8_t
496 simde_vbslq_s16(simde_uint16x8_t a, simde_int16x8_t b, simde_int16x8_t c) {
497 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
498 return vbslq_s16(a, b, c);
499 #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) || defined(SIMDE_ZARCH_ZVECTOR_13_NATIVE)
500 return vec_sel(c, b, a);
501 #else
502 simde_uint16x8_private
503 r_,
504 a_ = simde_uint16x8_to_private(a),
505 b_ = simde_uint16x8_to_private(simde_vreinterpretq_u16_s16(b)),
506 c_ = simde_uint16x8_to_private(simde_vreinterpretq_u16_s16(c));
507
508 #if defined(SIMDE_WASM_SIMD128_NATIVE)
509 r_.v128 = wasm_v128_bitselect(b_.v128, c_.v128, a_.v128);
510 #elif defined(SIMDE_X86_AVX512VL_NATIVE)
511 r_.m128i = _mm_ternarylogic_epi32(a_.m128i, b_.m128i, c_.m128i, 0xca);
512 #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
513 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
514 #else
515 SIMDE_VECTORIZE
516 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
517 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
518 }
519 #endif
520
521 return simde_vreinterpretq_s16_u16(simde_uint16x8_from_private(r_));
522 #endif
523 }
524 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
525 #undef vbslq_s16
526 #define vbslq_s16(a, b, c) simde_vbslq_s16((a), (b), (c))
527 #endif
528
529 SIMDE_FUNCTION_ATTRIBUTES
530 simde_int32x4_t
531 simde_vbslq_s32(simde_uint32x4_t a, simde_int32x4_t b, simde_int32x4_t c) {
532 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
533 return vbslq_s32(a, b, c);
534 #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) || defined(SIMDE_ZARCH_ZVECTOR_13_NATIVE)
535 return vec_sel(c, b, a);
536 #else
537 simde_uint32x4_private
538 r_,
539 a_ = simde_uint32x4_to_private(a),
540 b_ = simde_uint32x4_to_private(simde_vreinterpretq_u32_s32(b)),
541 c_ = simde_uint32x4_to_private(simde_vreinterpretq_u32_s32(c));
542
543 #if defined(SIMDE_WASM_SIMD128_NATIVE)
544 r_.v128 = wasm_v128_bitselect(b_.v128, c_.v128, a_.v128);
545 #elif defined(SIMDE_X86_AVX512VL_NATIVE)
546 r_.m128i = _mm_ternarylogic_epi32(a_.m128i, b_.m128i, c_.m128i, 0xca);
547 #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
548 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
549 #else
550 SIMDE_VECTORIZE
551 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
552 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
553 }
554 #endif
555
556 return simde_vreinterpretq_s32_u32(simde_uint32x4_from_private(r_));
557 #endif
558 }
559 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
560 #undef vbslq_s32
561 #define vbslq_s32(a, b, c) simde_vbslq_s32((a), (b), (c))
562 #endif
563
564 SIMDE_FUNCTION_ATTRIBUTES
565 simde_int64x2_t
566 simde_vbslq_s64(simde_uint64x2_t a, simde_int64x2_t b, simde_int64x2_t c) {
567 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
568 return vbslq_s64(a, b, c);
569 #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) || defined(SIMDE_ZARCH_ZVECTOR_13_NATIVE)
570 return
571 simde_vreinterpretq_s64_s32(
572 simde_vbslq_s32(
573 simde_vreinterpretq_u32_u64(a),
574 simde_vreinterpretq_s32_s64(b),
575 simde_vreinterpretq_s32_s64(c)
576 )
577 );
578 #elif defined(SIMDE_POWER_ALTIVEC_P8_NATIVE) || defined(SIMDE_ZARCH_ZVECTOR_13_NATIVE)
579 return vec_sel(
580 HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed long long), c),
581 HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed long long), b),
582 HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(unsigned long long), a));
583 #else
584 simde_uint64x2_private
585 r_,
586 a_ = simde_uint64x2_to_private(a),
587 b_ = simde_uint64x2_to_private(simde_vreinterpretq_u64_s64(b)),
588 c_ = simde_uint64x2_to_private(simde_vreinterpretq_u64_s64(c));
589
590 #if defined(SIMDE_WASM_SIMD128_NATIVE)
591 r_.v128 = wasm_v128_bitselect(b_.v128, c_.v128, a_.v128);
592 #elif defined(SIMDE_X86_AVX512VL_NATIVE)
593 r_.m128i = _mm_ternarylogic_epi32(a_.m128i, b_.m128i, c_.m128i, 0xca);
594 #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
595 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
596 #else
597 SIMDE_VECTORIZE
598 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
599 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
600 }
601 #endif
602
603 return simde_vreinterpretq_s64_u64(simde_uint64x2_from_private(r_));
604 #endif
605 }
606 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
607 #undef vbslq_s64
608 #define vbslq_s64(a, b, c) simde_vbslq_s64((a), (b), (c))
609 #endif
610
611 SIMDE_FUNCTION_ATTRIBUTES
612 simde_uint8x16_t
613 simde_vbslq_u8(simde_uint8x16_t a, simde_uint8x16_t b, simde_uint8x16_t c) {
614 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
615 return vbslq_u8(a, b, c);
616 #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) || defined(SIMDE_ZARCH_ZVECTOR_13_NATIVE)
617 return vec_sel(c, b, a);
618 #else
619 simde_uint8x16_private
620 r_,
621 a_ = simde_uint8x16_to_private(a),
622 b_ = simde_uint8x16_to_private(b),
623 c_ = simde_uint8x16_to_private(c);
624
625 #if defined(SIMDE_WASM_SIMD128_NATIVE)
626 r_.v128 = wasm_v128_bitselect(b_.v128, c_.v128, a_.v128);
627 #elif defined(SIMDE_X86_AVX512VL_NATIVE)
628 r_.m128i = _mm_ternarylogic_epi32(a_.m128i, b_.m128i, c_.m128i, 0xca);
629 #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
630 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
631 #else
632 SIMDE_VECTORIZE
633 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
634 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
635 }
636 #endif
637
638 return simde_uint8x16_from_private(r_);
639 #endif
640 }
641 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
642 #undef vbslq_u8
643 #define vbslq_u8(a, b, c) simde_vbslq_u8((a), (b), (c))
644 #endif
645
646 SIMDE_FUNCTION_ATTRIBUTES
647 simde_uint16x8_t
648 simde_vbslq_u16(simde_uint16x8_t a, simde_uint16x8_t b, simde_uint16x8_t c) {
649 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
650 return vbslq_u16(a, b, c);
651 #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) || defined(SIMDE_ZARCH_ZVECTOR_13_NATIVE)
652 return vec_sel(c, b, a);
653 #else
654 simde_uint16x8_private
655 r_,
656 a_ = simde_uint16x8_to_private(a),
657 b_ = simde_uint16x8_to_private(b),
658 c_ = simde_uint16x8_to_private(c);
659
660 #if defined(SIMDE_WASM_SIMD128_NATIVE)
661 r_.v128 = wasm_v128_bitselect(b_.v128, c_.v128, a_.v128);
662 #elif defined(SIMDE_X86_AVX512VL_NATIVE)
663 r_.m128i = _mm_ternarylogic_epi32(a_.m128i, b_.m128i, c_.m128i, 0xca);
664 #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
665 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
666 #else
667 SIMDE_VECTORIZE
668 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
669 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
670 }
671 #endif
672
673 return simde_uint16x8_from_private(r_);
674 #endif
675 }
676 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
677 #undef vbslq_u16
678 #define vbslq_u16(a, b, c) simde_vbslq_u16((a), (b), (c))
679 #endif
680
681 SIMDE_FUNCTION_ATTRIBUTES
682 simde_uint32x4_t
683 simde_vbslq_u32(simde_uint32x4_t a, simde_uint32x4_t b, simde_uint32x4_t c) {
684 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
685 return vbslq_u32(a, b, c);
686 #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) || defined(SIMDE_ZARCH_ZVECTOR_13_NATIVE)
687 return vec_sel(c, b, a);
688 #else
689 simde_uint32x4_private
690 r_,
691 a_ = simde_uint32x4_to_private(a),
692 b_ = simde_uint32x4_to_private(b),
693 c_ = simde_uint32x4_to_private(c);
694
695 #if defined(SIMDE_WASM_SIMD128_NATIVE)
696 r_.v128 = wasm_v128_bitselect(b_.v128, c_.v128, a_.v128);
697 #elif defined(SIMDE_X86_AVX512VL_NATIVE)
698 r_.m128i = _mm_ternarylogic_epi32(a_.m128i, b_.m128i, c_.m128i, 0xca);
699 #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
700 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
701 #else
702 SIMDE_VECTORIZE
703 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
704 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
705 }
706 #endif
707
708 return simde_uint32x4_from_private(r_);
709 #endif
710 }
711 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
712 #undef vbslq_u32
713 #define vbslq_u32(a, b, c) simde_vbslq_u32((a), (b), (c))
714 #endif
715
716 SIMDE_FUNCTION_ATTRIBUTES
717 simde_uint64x2_t
718 simde_vbslq_u64(simde_uint64x2_t a, simde_uint64x2_t b, simde_uint64x2_t c) {
719 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
720 return vbslq_u64(a, b, c);
721 #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) || defined(SIMDE_ZARCH_ZVECTOR_13_NATIVE)
722 return
723 simde_vreinterpretq_u64_u32(
724 simde_vbslq_u32(
725 simde_vreinterpretq_u32_u64(a),
726 simde_vreinterpretq_u32_u64(b),
727 simde_vreinterpretq_u32_u64(c)
728 )
729 );
730 #else
731 simde_uint64x2_private
732 r_,
733 a_ = simde_uint64x2_to_private(a),
734 b_ = simde_uint64x2_to_private(b),
735 c_ = simde_uint64x2_to_private(c);
736
737 #if defined(SIMDE_WASM_SIMD128_NATIVE)
738 r_.v128 = wasm_v128_bitselect(b_.v128, c_.v128, a_.v128);
739 #elif defined(SIMDE_X86_AVX512VL_NATIVE)
740 r_.m128i = _mm_ternarylogic_epi32(a_.m128i, b_.m128i, c_.m128i, 0xca);
741 #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
742 r_.values = c_.values ^ ((b_.values ^ c_.values) & a_.values);
743 #else
744 SIMDE_VECTORIZE
745 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
746 r_.values[i] = (b_.values[i] & a_.values[i]) | (c_.values[i] & ~a_.values[i]);
747 }
748 #endif
749
750 return simde_uint64x2_from_private(r_);
751 #endif
752 }
753 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
754 #undef vbslq_u64
755 #define vbslq_u64(a, b, c) simde_vbslq_u64((a), (b), (c))
756 #endif
757
758 SIMDE_END_DECLS_
759 HEDLEY_DIAGNOSTIC_POP
760
761 #endif /* !defined(SIMDE_ARM_NEON_BSL_H) */