Skip to content

Commit 768579f

Browse files
committed
Rename the masked_store family of functions to store_select
1 parent 83c4eea commit 768579f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

crates/core_simd/src/vector.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -645,15 +645,15 @@ where
645645
/// let write = Simd::from_array([-5, -4, -3, -2]);
646646
/// let enable = Mask::from_array([false, true, true, true]);
647647
///
648-
/// write.masked_store(&mut arr[..3], enable);
648+
/// write.store_select(&mut arr[..3], enable);
649649
/// assert_eq!(arr, [0, -4, -3, 0]);
650650
/// ```
651651
#[inline]
652-
pub fn masked_store(self, slice: &mut [T], mut enable: Mask<<T as SimdElement>::Mask, N>) {
652+
pub fn store_select(self, slice: &mut [T], mut enable: Mask<<T as SimdElement>::Mask, N>) {
653653
enable &= mask_up_to(slice.len());
654654
// SAFETY: We performed the bounds check by updating the mask. &[T] is properly aligned to
655655
// the element.
656-
unsafe { self.masked_store_ptr(slice.as_mut_ptr(), enable) }
656+
unsafe { self.store_select_ptr(slice.as_mut_ptr(), enable) }
657657
}
658658

659659
/// Conditionally write contiguous elements to `slice`. The `enable` mask controls
@@ -673,18 +673,18 @@ where
673673
/// let write = Simd::from_array([-5, -4, -3, -2]);
674674
/// let enable = Mask::from_array([false, true, true, true]);
675675
///
676-
/// unsafe { write.masked_store_unchecked(&mut arr, enable) };
676+
/// unsafe { write.store_select_unchecked(&mut arr, enable) };
677677
/// assert_eq!(arr, [0, -4, -3, -3]);
678678
/// ```
679679
#[inline]
680-
pub unsafe fn masked_store_unchecked(
680+
pub unsafe fn store_select_unchecked(
681681
self,
682682
slice: &mut [T],
683683
enable: Mask<<T as SimdElement>::Mask, N>,
684684
) {
685685
let ptr = slice.as_mut_ptr();
686686
// SAFETY: The safety of writing elements in `slice` is ensured by the caller.
687-
unsafe { self.masked_store_ptr(ptr, enable) }
687+
unsafe { self.store_select_ptr(ptr, enable) }
688688
}
689689

690690
/// Conditionally write contiguous elements starting from `ptr`.
@@ -696,7 +696,7 @@ where
696696
/// Memory addresses for element are calculated [`core::ptr::wrapping_offset`] and
697697
/// each enabled element must satisfy the same conditions as [`core::ptr::write`].
698698
#[inline]
699-
pub unsafe fn masked_store_ptr(self, ptr: *mut T, enable: Mask<<T as SimdElement>::Mask, N>) {
699+
pub unsafe fn store_select_ptr(self, ptr: *mut T, enable: Mask<<T as SimdElement>::Mask, N>) {
700700
// SAFETY: The safety of writing elements through `ptr` is ensured by the caller.
701701
unsafe { core::intrinsics::simd::simd_masked_store(enable.to_int(), ptr, self) }
702702
}

crates/core_simd/tests/masked_load_store.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ wasm_bindgen_test_configure!(run_in_browser);
1212
fn masked_load_store() {
1313
let mut arr = [u8::MAX; 7];
1414

15-
u8x4::splat(0).masked_store(&mut arr[5..], Mask::from_array([false, true, false, true]));
15+
u8x4::splat(0).store_select(&mut arr[5..], Mask::from_array([false, true, false, true]));
1616
// write to index 8 is OOB and dropped
1717
assert_eq!(arr, [255u8, 255, 255, 255, 255, 255, 0]);
1818

19-
u8x4::from_array([0, 1, 2, 3]).masked_store(&mut arr[1..], Mask::splat(true));
19+
u8x4::from_array([0, 1, 2, 3]).store_select(&mut arr[1..], Mask::splat(true));
2020
assert_eq!(arr, [255u8, 0, 1, 2, 3, 255, 0]);
2121

2222
// read from index 8 is OOB and dropped

0 commit comments

Comments
 (0)