@@ -287,34 +287,72 @@ LIBC_INLINE constexpr static T hmax(simd<T, N> v) {
287287}
288288
289289//  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));
292294 T tmp;
293-  __builtin_memcpy (&tmp, ptr, sizeof (T));
295+  __builtin_memcpy_inline (
296+  &tmp, reinterpret_cast <const  simd_element_type_t <T> *>(ptr), sizeof (T));
294297 return  tmp;
295298}
296299template  <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)));
300+ LIBC_INLINE constexpr  static  void  store (T v, void  *ptr, bool  aligned = false ) {
301+  if  (aligned)
302+  ptr = __builtin_assume_aligned (ptr, alignof (T));
303+  __builtin_memcpy_inline (ptr, &v, sizeof (T));
299304}
300305template  <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));
306+ LIBC_INLINE constexpr  static  T
307+ load_masked (simd<bool , simd_size_v<T>> mask, const  void  *ptr,
308+  T passthru = internal::poison<T>(), bool aligned = false) {
309+  if  (aligned)
310+  ptr = __builtin_assume_aligned (ptr, alignof (T));
311+  return  __builtin_masked_load (
312+  mask, reinterpret_cast <const  simd_element_type_t <T> *>(ptr), passthru);
303313}
304314template  <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)));
315+ LIBC_INLINE constexpr  static  void  store_masked (simd<bool , simd_size_v<T>> mask,
316+  T v, void  *ptr,
317+  bool  aligned = false ) {
318+  if  (aligned)
319+  ptr = __builtin_assume_aligned (ptr, alignof (T));
320+  __builtin_masked_store (mask, v,
321+  reinterpret_cast <simd_element_type_t <T> *>(ptr));
322+ }
323+ template  <typename  T, typename  Idx, internal::enable_if_simd_t <T> = 0 >
324+ LIBC_INLINE constexpr  static  T gather (simd<bool , simd_size_v<T>> mask, Idx idx,
325+  const  void  *base, bool  aligned = false ) {
326+  if  (aligned)
327+  base = __builtin_assume_aligned (base, alignof (T));
328+  return  __builtin_masked_gather (
329+  mask, idx, reinterpret_cast <const  simd_element_type_t <T> *>(base));
330+ }
331+ template  <typename  T, typename  Idx, internal::enable_if_simd_t <T> = 0 >
332+ LIBC_INLINE constexpr  static  void  scatter (simd<bool , simd_size_v<T>> mask,
333+  Idx idx, T v, void  *base,
334+  bool  aligned = false ) {
335+  if  (aligned)
336+  base = __builtin_assume_aligned (base, alignof (T));
337+  __builtin_masked_scatter (mask, idx, v,
338+  reinterpret_cast <simd_element_type_t <T> *>(base));
307339}
308340template  <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);
341+ LIBC_INLINE constexpr  static  T
342+ expand (simd<bool , simd_size_v<T>> mask, const  void  *ptr,
343+  T passthru = internal::poison<T>(), bool aligned = false) {
344+  if  (aligned)
345+  ptr = __builtin_assume_aligned (ptr, alignof (T));
346+  return  __builtin_masked_expand_load (
347+  mask, reinterpret_cast <const  simd_element_type_t <T> *>(ptr), passthru);
313348}
314349template  <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))));
350+ LIBC_INLINE constexpr  static  void  compress (simd<bool , simd_size_v<T>> mask, T v,
351+  void  *ptr, bool  aligned = false ) {
352+  if  (aligned)
353+  ptr = __builtin_assume_aligned (ptr, alignof (T));
354+  __builtin_masked_compress_store (
355+  mask, v, reinterpret_cast <simd_element_type_t <T> *>(ptr));
318356}
319357
320358//  Construction helpers.
0 commit comments