@@ -287,34 +287,68 @@ LIBC_INLINE constexpr static T hmax(simd<T, N> v) {
287
287
}
288
288
289
289
// Accessor helpers.
290
- template <typename T, internal::enable_if_simd_t <T> = 0 >
291
- LIBC_INLINE T load_unaligned (const void *ptr) {
290
+ template <typename T>
291
+ LIBC_INLINE T constexpr static load (const void *ptr, bool aligned = false ) {
292
+ if (aligned)
293
+ ptr = __builtin_assume_aligned (ptr, alignof (T));
292
294
T tmp;
293
- __builtin_memcpy (&tmp, ptr, sizeof (T));
295
+ __builtin_memcpy (&tmp, reinterpret_cast < const T *>( ptr) , sizeof (T));
294
296
return tmp;
295
297
}
296
298
template <typename T, internal::enable_if_simd_t <T> = 0 >
297
- LIBC_INLINE T load_aligned (const void *ptr) {
298
- return load_unaligned<T>(__builtin_assume_aligned (ptr, alignof (T)));
299
+ LIBC_INLINE constexpr static void store (T v, void *ptr, bool aligned = false ) {
300
+ if (aligned)
301
+ ptr = __builtin_assume_aligned (ptr, alignof (T));
302
+ __builtin_memcpy (ptr, &v, sizeof (T));
299
303
}
300
304
template <typename T, internal::enable_if_simd_t <T> = 0 >
301
- LIBC_INLINE T store_unaligned (T v, void *ptr) {
302
- __builtin_memcpy (ptr, &v, sizeof (T));
305
+ LIBC_INLINE constexpr static T
306
+ load_masked (simd<bool , simd_size_v<T>> mask, void *ptr,
307
+ T passthru = internal::poison<T>(), bool aligned = false) {
308
+ if (aligned)
309
+ ptr = __builtin_assume_aligned (ptr, alignof (T));
310
+ return __builtin_masked_load (mask, reinterpret_cast <T *>(ptr), passthru);
303
311
}
304
312
template <typename T, internal::enable_if_simd_t <T> = 0 >
305
- LIBC_INLINE T store_aligned (T v, void *ptr) {
306
- store_unaligned<T>(v, __builtin_assume_aligned (ptr, alignof (T)));
313
+ LIBC_INLINE constexpr static void store_masked (simd<bool , simd_size_v<T>> mask,
314
+ T v, void *ptr,
315
+ bool aligned = false ) {
316
+ if (aligned)
317
+ ptr = __builtin_assume_aligned (ptr, alignof (T));
318
+ __builtin_masked_store (mask, v, reinterpret_cast <T *>(ptr));
319
+ }
320
+ template <typename T, typename Idx, internal::enable_if_simd_t <T> = 0 >
321
+ LIBC_INLINE constexpr static T gather (simd<bool , simd_size_v<T>> mask, Idx idx,
322
+ void *base, bool aligned = false ) {
323
+ if (aligned)
324
+ base = __builtin_assume_aligned (base, alignof (T));
325
+ return __builtin_masked_gather (
326
+ mask, idx, reinterpret_cast <simd_element_type_t <T> *>(base));
327
+ }
328
+ template <typename T, typename Idx, internal::enable_if_simd_t <T> = 0 >
329
+ LIBC_INLINE constexpr static void scatter (simd<bool , simd_size_v<T>> mask,
330
+ Idx idx, T v, void *base,
331
+ bool aligned = false ) {
332
+ if (aligned)
333
+ base = __builtin_assume_aligned (base, alignof (T));
334
+ __builtin_masked_scatter (mask, idx, v,
335
+ reinterpret_cast <simd_element_type_t <T> *>(base));
307
336
}
308
337
template <typename T, internal::enable_if_simd_t <T> = 0 >
309
- LIBC_INLINE T
310
- masked_load (simd<bool , simd_size_v<T>> m, void *ptr,
311
- T passthru = internal::poison<simd_element_type<T>>()) {
312
- return __builtin_masked_load (m, ptr, passthru);
338
+ LIBC_INLINE constexpr static T
339
+ expand (simd<bool , simd_size_v<T>> mask, void *ptr,
340
+ T passthru = internal::poison<T>(), bool aligned = false) {
341
+ if (aligned)
342
+ ptr = __builtin_assume_aligned (ptr, alignof (T));
343
+ return __builtin_masked_expand_load (mask, reinterpret_cast <T *>(ptr),
344
+ passthru);
313
345
}
314
346
template <typename T, internal::enable_if_simd_t <T> = 0 >
315
- LIBC_INLINE T masked_store (simd<bool , simd_size_v<T>> m, T v, void *ptr) {
316
- __builtin_masked_store (
317
- m, v, static_cast <T *>(__builtin_assume_aligned (ptr, alignof (T))));
347
+ LIBC_INLINE constexpr static void compress (simd<bool , simd_size_v<T>> mask, T v,
348
+ void *ptr, bool aligned = false ) {
349
+ if (aligned)
350
+ ptr = __builtin_assume_aligned (ptr, alignof (T));
351
+ __builtin_masked_compress_store (mask, v, reinterpret_cast <T *>(ptr));
318
352
}
319
353
320
354
// Construction helpers.
0 commit comments