| 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 |
* 2021 Atharva Nimbalkar <[email protected]> |
| 25 |
*/ |
| 26 |
|
| 27 |
#if !defined(SIMDE_ARM_NEON_QSHLU_N_H) |
| 28 |
#define SIMDE_ARM_NEON_QSHLU_N_H |
| 29 |
|
| 30 |
#include "types.h" |
| 31 |
#if defined(SIMDE_WASM_SIMD128_NATIVE) |
| 32 |
#include "reinterpret.h" |
| 33 |
#include "movl.h" |
| 34 |
#include "movn.h" |
| 35 |
#include "combine.h" |
| 36 |
#include "get_low.h" |
| 37 |
#endif |
| 38 |
|
| 39 |
HEDLEY_DIAGNOSTIC_PUSH |
| 40 |
SIMDE_DISABLE_UNWANTED_DIAGNOSTICS |
| 41 |
SIMDE_BEGIN_DECLS_ |
| 42 |
|
| 43 |
SIMDE_FUNCTION_ATTRIBUTES |
| 44 |
uint8_t |
| 45 |
simde_vqshlub_n_s8(int8_t a, const int n) |
| 46 |
SIMDE_REQUIRE_CONSTANT_RANGE(n, 0, 7) { |
| 47 |
uint8_t r = HEDLEY_STATIC_CAST(uint8_t, a << n); |
| 48 |
r |= (((r >> n) != HEDLEY_STATIC_CAST(uint8_t, a)) ? UINT8_MAX : 0); |
| 49 |
return (a < 0) ? 0 : r; |
| 50 |
} |
| 51 |
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) |
| 52 |
#define simde_vqshlub_n_s8(a, n) HEDLEY_STATIC_CAST(uint8_t, vqshlub_n_s8(a, n)) |
| 53 |
#endif |
| 54 |
#if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES) |
| 55 |
#undef vqshlub_n_s8 |
| 56 |
#define vqshlub_n_s8(a, n) simde_vqshlub_n_s8((a), (n)) |
| 57 |
#endif |
| 58 |
|
| 59 |
SIMDE_FUNCTION_ATTRIBUTES |
| 60 |
uint32_t |
| 61 |
simde_vqshlus_n_s32(int32_t a, const int n) |
| 62 |
SIMDE_REQUIRE_CONSTANT_RANGE(n, 0, 31) { |
| 63 |
uint32_t r = HEDLEY_STATIC_CAST(uint32_t, a << n); |
| 64 |
r |= (((r >> n) != HEDLEY_STATIC_CAST(uint32_t, a)) ? UINT32_MAX : 0); |
| 65 |
return (a < 0) ? 0 : r; |
| 66 |
} |
| 67 |
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) |
| 68 |
#define simde_vqshlus_n_s32(a, n) HEDLEY_STATIC_CAST(uint32_t, vqshlus_n_s32(a, n)) |
| 69 |
#endif |
| 70 |
#if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES) |
| 71 |
#undef vqshlus_n_s32 |
| 72 |
#define vqshlus_n_s32(a, n) simde_vqshlus_n_s32((a), (n)) |
| 73 |
#endif |
| 74 |
|
| 75 |
SIMDE_FUNCTION_ATTRIBUTES |
| 76 |
uint64_t |
| 77 |
simde_vqshlud_n_s64(int64_t a, const int n) |
| 78 |
SIMDE_REQUIRE_CONSTANT_RANGE(n, 0, 63) { |
| 79 |
uint32_t r = HEDLEY_STATIC_CAST(uint32_t, a << n); |
| 80 |
r |= (((r >> n) != HEDLEY_STATIC_CAST(uint32_t, a)) ? UINT32_MAX : 0); |
| 81 |
return (a < 0) ? 0 : r; |
| 82 |
} |
| 83 |
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) |
| 84 |
#define simde_vqshlud_n_s64(a, n) HEDLEY_STATIC_CAST(uint64_t, vqshlud_n_s64(a, n)) |
| 85 |
#endif |
| 86 |
#if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES) |
| 87 |
#undef vqshlud_n_s64 |
| 88 |
#define vqshlud_n_s64(a, n) simde_vqshlud_n_s64((a), (n)) |
| 89 |
#endif |
| 90 |
|
| 91 |
SIMDE_FUNCTION_ATTRIBUTES |
| 92 |
simde_uint8x8_t |
| 93 |
simde_vqshlu_n_s8(simde_int8x8_t a, const int n) |
| 94 |
SIMDE_REQUIRE_CONSTANT_RANGE(n, 0, 7) { |
| 95 |
#if defined(SIMDE_WASM_SIMD128_NATIVE) |
| 96 |
simde_int16x8_private |
| 97 |
R_, |
| 98 |
A_ = simde_int16x8_to_private(simde_vmovl_s8(a)); |
| 99 |
|
| 100 |
const v128_t shifted = wasm_i16x8_shl(A_.v128, HEDLEY_STATIC_CAST(uint32_t, n)); |
| 101 |
R_.v128 = wasm_i16x8_min(shifted, wasm_i16x8_const_splat(UINT8_MAX)); |
| 102 |
R_.v128 = wasm_i16x8_max(R_.v128, wasm_i16x8_const_splat(0)); |
| 103 |
|
| 104 |
return simde_vmovn_u16(simde_vreinterpretq_u16_s16( simde_int16x8_from_private(R_))); |
| 105 |
#else |
| 106 |
simde_int8x8_private a_ = simde_int8x8_to_private(a); |
| 107 |
simde_uint8x8_private r_; |
| 108 |
|
| 109 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_100762) |
| 110 |
__typeof__(r_.values) shifted = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values) << n; |
| 111 |
|
| 112 |
__typeof__(r_.values) overflow = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (shifted >> n) != HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values)); |
| 113 |
|
| 114 |
r_.values = (shifted & ~overflow) | overflow; |
| 115 |
|
| 116 |
r_.values &= HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (a_.values >= 0)); |
| 117 |
#else |
| 118 |
SIMDE_VECTORIZE |
| 119 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 120 |
r_.values[i] = HEDLEY_STATIC_CAST(uint8_t, a_.values[i] << n); |
| 121 |
r_.values[i] |= (((r_.values[i] >> n) != HEDLEY_STATIC_CAST(uint8_t, a_.values[i])) ? UINT8_MAX : 0); |
| 122 |
r_.values[i] = (a_.values[i] < 0) ? 0 : r_.values[i]; |
| 123 |
} |
| 124 |
#endif |
| 125 |
|
| 126 |
return simde_uint8x8_from_private(r_); |
| 127 |
#endif |
| 128 |
} |
| 129 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 130 |
#define simde_vqshlu_n_s8(a, n) vqshlu_n_s8(a, n) |
| 131 |
#endif |
| 132 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 133 |
#undef vqshlu_n_s8 |
| 134 |
#define vqshlu_n_s8(a, n) simde_vqshlu_n_s8((a), (n)) |
| 135 |
#endif |
| 136 |
|
| 137 |
SIMDE_FUNCTION_ATTRIBUTES |
| 138 |
simde_uint16x4_t |
| 139 |
simde_vqshlu_n_s16(simde_int16x4_t a, const int n) |
| 140 |
SIMDE_REQUIRE_CONSTANT_RANGE(n, 0, 15) { |
| 141 |
#if defined(SIMDE_WASM_SIMD128_NATIVE) |
| 142 |
simde_int32x4_private |
| 143 |
R_, |
| 144 |
A_ = simde_int32x4_to_private(simde_vmovl_s16(a)); |
| 145 |
|
| 146 |
const v128_t shifted = wasm_i32x4_shl(A_.v128, HEDLEY_STATIC_CAST(uint32_t, n)); |
| 147 |
R_.v128 = wasm_i32x4_min(shifted, wasm_i32x4_const_splat(UINT16_MAX)); |
| 148 |
R_.v128 = wasm_i32x4_max(R_.v128, wasm_i32x4_const_splat(0)); |
| 149 |
|
| 150 |
return simde_vmovn_u32(simde_vreinterpretq_u32_s32( simde_int32x4_from_private(R_))); |
| 151 |
#else |
| 152 |
simde_int16x4_private a_ = simde_int16x4_to_private(a); |
| 153 |
simde_uint16x4_private r_; |
| 154 |
|
| 155 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_100762) |
| 156 |
__typeof__(r_.values) shifted = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values) << n; |
| 157 |
|
| 158 |
__typeof__(r_.values) overflow = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (shifted >> n) != HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values)); |
| 159 |
|
| 160 |
r_.values = (shifted & ~overflow) | overflow; |
| 161 |
|
| 162 |
r_.values &= HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (a_.values >= 0)); |
| 163 |
#else |
| 164 |
SIMDE_VECTORIZE |
| 165 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 166 |
r_.values[i] = HEDLEY_STATIC_CAST(uint16_t, a_.values[i] << n); |
| 167 |
r_.values[i] |= (((r_.values[i] >> n) != HEDLEY_STATIC_CAST(uint16_t, a_.values[i])) ? UINT16_MAX : 0); |
| 168 |
r_.values[i] = (a_.values[i] < 0) ? 0 : r_.values[i]; |
| 169 |
} |
| 170 |
#endif |
| 171 |
|
| 172 |
return simde_uint16x4_from_private(r_); |
| 173 |
#endif |
| 174 |
} |
| 175 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 176 |
#define simde_vqshlu_n_s16(a, n) vqshlu_n_s16(a, n) |
| 177 |
#endif |
| 178 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 179 |
#undef vqshlu_n_s16 |
| 180 |
#define vqshlu_n_s16(a, n) simde_vqshlu_n_s16((a), (n)) |
| 181 |
#endif |
| 182 |
|
| 183 |
SIMDE_FUNCTION_ATTRIBUTES |
| 184 |
simde_uint32x2_t |
| 185 |
simde_vqshlu_n_s32(simde_int32x2_t a, const int n) |
| 186 |
SIMDE_REQUIRE_CONSTANT_RANGE(n, 0, 31) { |
| 187 |
#if defined(SIMDE_WASM_SIMD128_NATIVE) |
| 188 |
simde_int64x2_private |
| 189 |
R_, |
| 190 |
A_ = simde_int64x2_to_private(simde_vmovl_s32(a)); |
| 191 |
|
| 192 |
const v128_t max = wasm_i64x2_const_splat(UINT32_MAX); |
| 193 |
|
| 194 |
const v128_t shifted = wasm_i64x2_shl(A_.v128, HEDLEY_STATIC_CAST(uint32_t, n)); |
| 195 |
R_.v128 = wasm_v128_bitselect(shifted, max, wasm_i64x2_gt(max, shifted)); |
| 196 |
R_.v128 = wasm_v128_and(R_.v128, wasm_i64x2_gt(R_.v128, wasm_i64x2_const_splat(0))); |
| 197 |
|
| 198 |
return simde_vmovn_u64(simde_vreinterpretq_u64_s64( simde_int64x2_from_private(R_))); |
| 199 |
#else |
| 200 |
simde_int32x2_private a_ = simde_int32x2_to_private(a); |
| 201 |
simde_uint32x2_private r_; |
| 202 |
|
| 203 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_100762) |
| 204 |
__typeof__(r_.values) shifted = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values) << n; |
| 205 |
|
| 206 |
__typeof__(r_.values) overflow = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (shifted >> n) != HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values)); |
| 207 |
|
| 208 |
r_.values = (shifted & ~overflow) | overflow; |
| 209 |
|
| 210 |
r_.values &= HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (a_.values >= 0)); |
| 211 |
#else |
| 212 |
SIMDE_VECTORIZE |
| 213 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 214 |
r_.values[i] = HEDLEY_STATIC_CAST(uint32_t, a_.values[i] << n); |
| 215 |
r_.values[i] |= (((r_.values[i] >> n) != HEDLEY_STATIC_CAST(uint32_t, a_.values[i])) ? UINT32_MAX : 0); |
| 216 |
r_.values[i] = (a_.values[i] < 0) ? 0 : r_.values[i]; |
| 217 |
} |
| 218 |
#endif |
| 219 |
|
| 220 |
return simde_uint32x2_from_private(r_); |
| 221 |
#endif |
| 222 |
} |
| 223 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 224 |
#define simde_vqshlu_n_s32(a, n) vqshlu_n_s32(a, n) |
| 225 |
#endif |
| 226 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 227 |
#undef vqshlu_n_s32 |
| 228 |
#define vqshlu_n_s32(a, n) simde_vqshlu_n_s32((a), (n)) |
| 229 |
#endif |
| 230 |
|
| 231 |
SIMDE_FUNCTION_ATTRIBUTES |
| 232 |
simde_uint64x1_t |
| 233 |
simde_vqshlu_n_s64(simde_int64x1_t a, const int n) |
| 234 |
SIMDE_REQUIRE_CONSTANT_RANGE(n, 0, 63) { |
| 235 |
#if defined(SIMDE_WASM_SIMD128_NATIVE) |
| 236 |
simde_uint64x2_private |
| 237 |
R_, |
| 238 |
A_ = simde_uint64x2_to_private(simde_vreinterpretq_u64_s64(simde_vcombine_s64(a, a))); |
| 239 |
|
| 240 |
R_.v128 = wasm_i64x2_shl(A_.v128, HEDLEY_STATIC_CAST(uint32_t, n)); |
| 241 |
const v128_t overflow = wasm_i64x2_ne(A_.v128, wasm_u64x2_shr(R_.v128, HEDLEY_STATIC_CAST(uint32_t, n))); |
| 242 |
R_.v128 = wasm_v128_or(R_.v128, overflow); |
| 243 |
R_.v128 = wasm_v128_andnot(R_.v128, wasm_i64x2_shr(A_.v128, 63)); |
| 244 |
|
| 245 |
return simde_vget_low_u64(simde_uint64x2_from_private(R_)); |
| 246 |
#else |
| 247 |
simde_int64x1_private a_ = simde_int64x1_to_private(a); |
| 248 |
simde_uint64x1_private r_; |
| 249 |
|
| 250 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) |
| 251 |
__typeof__(r_.values) shifted = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values) << n; |
| 252 |
|
| 253 |
__typeof__(r_.values) overflow = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (shifted >> n) != HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values)); |
| 254 |
|
| 255 |
r_.values = (shifted & ~overflow) | overflow; |
| 256 |
|
| 257 |
r_.values &= HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (a_.values >= 0)); |
| 258 |
#else |
| 259 |
SIMDE_VECTORIZE |
| 260 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 261 |
r_.values[i] = HEDLEY_STATIC_CAST(uint64_t, a_.values[i] << n); |
| 262 |
r_.values[i] |= (((r_.values[i] >> n) != HEDLEY_STATIC_CAST(uint64_t, a_.values[i])) ? UINT64_MAX : 0); |
| 263 |
r_.values[i] = (a_.values[i] < 0) ? 0 : r_.values[i]; |
| 264 |
} |
| 265 |
#endif |
| 266 |
|
| 267 |
return simde_uint64x1_from_private(r_); |
| 268 |
#endif |
| 269 |
} |
| 270 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 271 |
#define simde_vqshlu_n_s64(a, n) vqshlu_n_s64(a, n) |
| 272 |
#endif |
| 273 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 274 |
#undef vqshlu_n_s64 |
| 275 |
#define vqshlu_n_s64(a, n) simde_vqshlu_n_s64((a), (n)) |
| 276 |
#endif |
| 277 |
|
| 278 |
SIMDE_FUNCTION_ATTRIBUTES |
| 279 |
simde_uint8x16_t |
| 280 |
simde_vqshluq_n_s8(simde_int8x16_t a, const int n) |
| 281 |
SIMDE_REQUIRE_CONSTANT_RANGE(n, 0, 7) { |
| 282 |
simde_int8x16_private a_ = simde_int8x16_to_private(a); |
| 283 |
simde_uint8x16_private r_; |
| 284 |
|
| 285 |
#if defined(SIMDE_WASM_SIMD128_NATIVE) |
| 286 |
r_.v128 = wasm_i8x16_shl(a_.v128, HEDLEY_STATIC_CAST(uint32_t, n)); |
| 287 |
const v128_t overflow = wasm_i8x16_ne(a_.v128, wasm_u8x16_shr(r_.v128, HEDLEY_STATIC_CAST(uint32_t, n))); |
| 288 |
r_.v128 = wasm_v128_or(r_.v128, overflow); |
| 289 |
r_.v128 = wasm_v128_andnot(r_.v128, wasm_i8x16_shr(a_.v128, 7)); |
| 290 |
#elif defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) |
| 291 |
__typeof__(r_.values) shifted = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values) << n; |
| 292 |
|
| 293 |
__typeof__(r_.values) overflow = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (shifted >> n) != HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values)); |
| 294 |
|
| 295 |
r_.values = (shifted & ~overflow) | overflow; |
| 296 |
|
| 297 |
r_.values &= HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (a_.values >= 0)); |
| 298 |
#else |
| 299 |
SIMDE_VECTORIZE |
| 300 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 301 |
r_.values[i] = HEDLEY_STATIC_CAST(uint8_t, a_.values[i] << n); |
| 302 |
r_.values[i] |= (((r_.values[i] >> n) != HEDLEY_STATIC_CAST(uint8_t, a_.values[i])) ? UINT8_MAX : 0); |
| 303 |
r_.values[i] = (a_.values[i] < 0) ? 0 : r_.values[i]; |
| 304 |
} |
| 305 |
#endif |
| 306 |
|
| 307 |
return simde_uint8x16_from_private(r_); |
| 308 |
} |
| 309 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 310 |
#define simde_vqshluq_n_s8(a, n) vqshluq_n_s8(a, n) |
| 311 |
#endif |
| 312 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 313 |
#undef vqshluq_n_s8 |
| 314 |
#define vqshluq_n_s8(a, n) simde_vqshluq_n_s8((a), (n)) |
| 315 |
#endif |
| 316 |
|
| 317 |
SIMDE_FUNCTION_ATTRIBUTES |
| 318 |
simde_uint16x8_t |
| 319 |
simde_vqshluq_n_s16(simde_int16x8_t a, const int n) |
| 320 |
SIMDE_REQUIRE_CONSTANT_RANGE(n, 0, 15) { |
| 321 |
simde_int16x8_private a_ = simde_int16x8_to_private(a); |
| 322 |
simde_uint16x8_private r_; |
| 323 |
|
| 324 |
#if defined(SIMDE_WASM_SIMD128_NATIVE) |
| 325 |
r_.v128 = wasm_i16x8_shl(a_.v128, HEDLEY_STATIC_CAST(uint32_t, n)); |
| 326 |
const v128_t overflow = wasm_i16x8_ne(a_.v128, wasm_u16x8_shr(r_.v128, HEDLEY_STATIC_CAST(uint32_t, n))); |
| 327 |
r_.v128 = wasm_v128_or(r_.v128, overflow); |
| 328 |
r_.v128 = wasm_v128_andnot(r_.v128, wasm_i16x8_shr(a_.v128, 15)); |
| 329 |
#elif defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) |
| 330 |
__typeof__(r_.values) shifted = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values) << n; |
| 331 |
|
| 332 |
__typeof__(r_.values) overflow = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (shifted >> n) != HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values)); |
| 333 |
|
| 334 |
r_.values = (shifted & ~overflow) | overflow; |
| 335 |
|
| 336 |
r_.values &= HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (a_.values >= 0)); |
| 337 |
#else |
| 338 |
SIMDE_VECTORIZE |
| 339 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 340 |
r_.values[i] = HEDLEY_STATIC_CAST(uint16_t, a_.values[i] << n); |
| 341 |
r_.values[i] |= (((r_.values[i] >> n) != HEDLEY_STATIC_CAST(uint16_t, a_.values[i])) ? UINT16_MAX : 0); |
| 342 |
r_.values[i] = (a_.values[i] < 0) ? 0 : r_.values[i]; |
| 343 |
} |
| 344 |
#endif |
| 345 |
|
| 346 |
return simde_uint16x8_from_private(r_); |
| 347 |
} |
| 348 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 349 |
#define simde_vqshluq_n_s16(a, n) vqshluq_n_s16(a, n) |
| 350 |
#endif |
| 351 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 352 |
#undef vqshluq_n_s16 |
| 353 |
#define vqshluq_n_s16(a, n) simde_vqshluq_n_s16((a), (n)) |
| 354 |
#endif |
| 355 |
|
| 356 |
SIMDE_FUNCTION_ATTRIBUTES |
| 357 |
simde_uint32x4_t |
| 358 |
simde_vqshluq_n_s32(simde_int32x4_t a, const int n) |
| 359 |
SIMDE_REQUIRE_CONSTANT_RANGE(n, 0, 31) { |
| 360 |
simde_int32x4_private a_ = simde_int32x4_to_private(a); |
| 361 |
simde_uint32x4_private r_; |
| 362 |
|
| 363 |
#if defined(SIMDE_WASM_SIMD128_NATIVE) |
| 364 |
r_.v128 = wasm_i32x4_shl(a_.v128, HEDLEY_STATIC_CAST(uint32_t, n)); |
| 365 |
const v128_t overflow = wasm_i32x4_ne(a_.v128, wasm_u32x4_shr(r_.v128, HEDLEY_STATIC_CAST(uint32_t, n))); |
| 366 |
r_.v128 = wasm_v128_or(r_.v128, overflow); |
| 367 |
r_.v128 = wasm_v128_andnot(r_.v128, wasm_i32x4_shr(a_.v128, 31)); |
| 368 |
#elif defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) |
| 369 |
__typeof__(r_.values) shifted = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values) << n; |
| 370 |
|
| 371 |
__typeof__(r_.values) overflow = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (shifted >> n) != HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values)); |
| 372 |
|
| 373 |
r_.values = (shifted & ~overflow) | overflow; |
| 374 |
|
| 375 |
r_.values &= HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (a_.values >= 0)); |
| 376 |
#else |
| 377 |
SIMDE_VECTORIZE |
| 378 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 379 |
r_.values[i] = HEDLEY_STATIC_CAST(uint32_t, a_.values[i] << n); |
| 380 |
r_.values[i] |= (((r_.values[i] >> n) != HEDLEY_STATIC_CAST(uint32_t, a_.values[i])) ? UINT32_MAX : 0); |
| 381 |
r_.values[i] = (a_.values[i] < 0) ? 0 : r_.values[i]; |
| 382 |
} |
| 383 |
#endif |
| 384 |
|
| 385 |
return simde_uint32x4_from_private(r_); |
| 386 |
} |
| 387 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 388 |
#define simde_vqshluq_n_s32(a, n) vqshluq_n_s32(a, n) |
| 389 |
#endif |
| 390 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 391 |
#undef vqshluq_n_s32 |
| 392 |
#define vqshluq_n_s32(a, n) simde_vqshluq_n_s32((a), (n)) |
| 393 |
#endif |
| 394 |
|
| 395 |
SIMDE_FUNCTION_ATTRIBUTES |
| 396 |
simde_uint64x2_t |
| 397 |
simde_vqshluq_n_s64(simde_int64x2_t a, const int n) |
| 398 |
SIMDE_REQUIRE_CONSTANT_RANGE(n, 0, 63) { |
| 399 |
simde_int64x2_private a_ = simde_int64x2_to_private(a); |
| 400 |
simde_uint64x2_private r_; |
| 401 |
|
| 402 |
#if defined(SIMDE_WASM_SIMD128_NATIVE) |
| 403 |
r_.v128 = wasm_i64x2_shl(a_.v128, HEDLEY_STATIC_CAST(uint32_t, n)); |
| 404 |
const v128_t overflow = wasm_i64x2_ne(a_.v128, wasm_u64x2_shr(r_.v128, HEDLEY_STATIC_CAST(uint32_t, n))); |
| 405 |
r_.v128 = wasm_v128_or(r_.v128, overflow); |
| 406 |
r_.v128 = wasm_v128_andnot(r_.v128, wasm_i64x2_shr(a_.v128, 63)); |
| 407 |
#elif defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) |
| 408 |
__typeof__(r_.values) shifted = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values) << n; |
| 409 |
|
| 410 |
__typeof__(r_.values) overflow = HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (shifted >> n) != HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), a_.values)); |
| 411 |
|
| 412 |
r_.values = (shifted & ~overflow) | overflow; |
| 413 |
|
| 414 |
r_.values &= HEDLEY_REINTERPRET_CAST(__typeof__(r_.values), (a_.values >= 0)); |
| 415 |
#else |
| 416 |
SIMDE_VECTORIZE |
| 417 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 418 |
r_.values[i] = HEDLEY_STATIC_CAST(uint64_t, a_.values[i] << n); |
| 419 |
r_.values[i] |= (((r_.values[i] >> n) != HEDLEY_STATIC_CAST(uint64_t, a_.values[i])) ? UINT64_MAX : 0); |
| 420 |
r_.values[i] = (a_.values[i] < 0) ? 0 : r_.values[i]; |
| 421 |
} |
| 422 |
#endif |
| 423 |
|
| 424 |
return simde_uint64x2_from_private(r_); |
| 425 |
} |
| 426 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 427 |
#define simde_vqshluq_n_s64(a, n) vqshluq_n_s64(a, n) |
| 428 |
#endif |
| 429 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 430 |
#undef vqshluq_n_s64 |
| 431 |
#define vqshluq_n_s64(a, n) simde_vqshluq_n_s64((a), (n)) |
| 432 |
#endif |
| 433 |
|
| 434 |
SIMDE_END_DECLS_ |
| 435 |
HEDLEY_DIAGNOSTIC_POP |
| 436 |
|
| 437 |
#endif /* !defined(SIMDE_ARM_NEON_QSHLU_N_H) */ |