Rename Mask::from_int_unchecked to Mask::from_simd_unchecked
This commit is contained in:
parent
42409f05bf
commit
3a70dd6a69
7 changed files with 39 additions and 37 deletions
|
|
@ -157,7 +157,7 @@ where
|
|||
let bytes: [u8; N] = mem::transmute_copy(&array);
|
||||
let bools: Simd<i8, N> =
|
||||
core::intrinsics::simd::simd_ne(Simd::from_array(bytes), Simd::splat(0u8));
|
||||
Mask::from_int_unchecked(core::intrinsics::simd::simd_cast(bools))
|
||||
Mask::from_simd_unchecked(core::intrinsics::simd::simd_cast(bools))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -188,11 +188,11 @@ where
|
|||
/// All elements must be either 0 or -1.
|
||||
#[inline]
|
||||
#[must_use = "method returns a new mask and does not mutate the original value"]
|
||||
pub unsafe fn from_int_unchecked(value: Simd<T, N>) -> Self {
|
||||
pub unsafe fn from_simd_unchecked(value: Simd<T, N>) -> Self {
|
||||
// Safety: the caller must confirm this invariant
|
||||
unsafe {
|
||||
core::intrinsics::assume(<T as Sealed>::valid(value));
|
||||
Self(mask_impl::Mask::from_int_unchecked(value))
|
||||
Self(mask_impl::Mask::from_simd_unchecked(value))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +207,7 @@ where
|
|||
pub fn from_simd(value: Simd<T, N>) -> Self {
|
||||
assert!(T::valid(value), "all values must be either 0 or -1",);
|
||||
// Safety: the validity has been checked
|
||||
unsafe { Self::from_int_unchecked(value) }
|
||||
unsafe { Self::from_simd_unchecked(value) }
|
||||
}
|
||||
|
||||
/// Converts the mask to a vector of integers, where 0 represents `false` and -1
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ where
|
|||
|
||||
#[inline]
|
||||
#[must_use = "method returns a new mask and does not mutate the original value"]
|
||||
pub(crate) unsafe fn from_int_unchecked(value: Simd<T, N>) -> Self {
|
||||
pub(crate) unsafe fn from_simd_unchecked(value: Simd<T, N>) -> Self {
|
||||
unsafe { Self(core::intrinsics::simd::simd_bitmask(value), PhantomData) }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ where
|
|||
|
||||
#[inline]
|
||||
#[must_use = "method returns a new mask and does not mutate the original value"]
|
||||
pub(crate) unsafe fn from_int_unchecked(value: Simd<T, N>) -> Self {
|
||||
pub(crate) unsafe fn from_simd_unchecked(value: Simd<T, N>) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ where
|
|||
};
|
||||
|
||||
// SAFETY: `mask` only contains `T::TRUE` or `T::FALSE`
|
||||
unsafe { Self::from_int_unchecked(mask.resize::<N>(T::FALSE)) }
|
||||
unsafe { Self::from_simd_unchecked(mask.resize::<N>(T::FALSE)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
|||
|
|
@ -30,14 +30,14 @@ macro_rules! impl_number {
|
|||
fn simd_eq(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_eq(self, other)) }
|
||||
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_eq(self, other)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn simd_ne(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_ne(self, other)) }
|
||||
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_ne(self, other)) }
|
||||
}
|
||||
}
|
||||
)*
|
||||
|
|
@ -59,14 +59,14 @@ macro_rules! impl_mask {
|
|||
fn simd_eq(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_eq(self.to_simd(), other.to_simd())) }
|
||||
unsafe { Self::from_simd_unchecked(core::intrinsics::simd::simd_eq(self.to_simd(), other.to_simd())) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn simd_ne(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_ne(self.to_simd(), other.to_simd())) }
|
||||
unsafe { Self::from_simd_unchecked(core::intrinsics::simd::simd_ne(self.to_simd(), other.to_simd())) }
|
||||
}
|
||||
}
|
||||
)*
|
||||
|
|
|
|||
|
|
@ -56,28 +56,28 @@ macro_rules! impl_integer {
|
|||
fn simd_lt(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_lt(self, other)) }
|
||||
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_lt(self, other)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn simd_le(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_le(self, other)) }
|
||||
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_le(self, other)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn simd_gt(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_gt(self, other)) }
|
||||
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_gt(self, other)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn simd_ge(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_ge(self, other)) }
|
||||
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_ge(self, other)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -122,28 +122,28 @@ macro_rules! impl_float {
|
|||
fn simd_lt(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_lt(self, other)) }
|
||||
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_lt(self, other)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn simd_le(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_le(self, other)) }
|
||||
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_le(self, other)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn simd_gt(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_gt(self, other)) }
|
||||
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_gt(self, other)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn simd_ge(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_ge(self, other)) }
|
||||
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_ge(self, other)) }
|
||||
}
|
||||
}
|
||||
)*
|
||||
|
|
@ -163,28 +163,28 @@ macro_rules! impl_mask {
|
|||
fn simd_lt(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_lt(self.to_simd(), other.to_simd())) }
|
||||
unsafe { Self::from_simd_unchecked(core::intrinsics::simd::simd_lt(self.to_simd(), other.to_simd())) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn simd_le(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_le(self.to_simd(), other.to_simd())) }
|
||||
unsafe { Self::from_simd_unchecked(core::intrinsics::simd::simd_le(self.to_simd(), other.to_simd())) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn simd_gt(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_gt(self.to_simd(), other.to_simd())) }
|
||||
unsafe { Self::from_simd_unchecked(core::intrinsics::simd::simd_gt(self.to_simd(), other.to_simd())) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn simd_ge(self, other: Self) -> Self::Mask {
|
||||
// Safety: `self` is a vector, and the result of the comparison
|
||||
// is always a valid mask.
|
||||
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_ge(self.to_simd(), other.to_simd())) }
|
||||
unsafe { Self::from_simd_unchecked(core::intrinsics::simd::simd_ge(self.to_simd(), other.to_simd())) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ pub trait Swizzle<const N: usize> {
|
|||
LaneCount<M>: SupportedLaneCount,
|
||||
{
|
||||
// SAFETY: all elements of this mask come from another mask
|
||||
unsafe { Mask::from_int_unchecked(Self::swizzle(mask.to_simd())) }
|
||||
unsafe { Mask::from_simd_unchecked(Self::swizzle(mask.to_simd())) }
|
||||
}
|
||||
|
||||
/// Creates a new mask from the elements of `first` and `second`.
|
||||
|
|
@ -181,7 +181,9 @@ pub trait Swizzle<const N: usize> {
|
|||
LaneCount<M>: SupportedLaneCount,
|
||||
{
|
||||
// SAFETY: all elements of this mask come from another mask
|
||||
unsafe { Mask::from_int_unchecked(Self::concat_swizzle(first.to_simd(), second.to_simd())) }
|
||||
unsafe {
|
||||
Mask::from_simd_unchecked(Self::concat_swizzle(first.to_simd(), second.to_simd()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -524,7 +526,7 @@ where
|
|||
#[must_use = "method returns a new vector and does not mutate the original inputs"]
|
||||
pub fn reverse(self) -> Self {
|
||||
// Safety: swizzles are safe for masks
|
||||
unsafe { Self::from_int_unchecked(self.to_simd().reverse()) }
|
||||
unsafe { Self::from_simd_unchecked(self.to_simd().reverse()) }
|
||||
}
|
||||
|
||||
/// Rotates the mask such that the first `OFFSET` elements of the slice move to the end
|
||||
|
|
@ -534,7 +536,7 @@ where
|
|||
#[must_use = "method returns a new vector and does not mutate the original inputs"]
|
||||
pub fn rotate_elements_left<const OFFSET: usize>(self) -> Self {
|
||||
// Safety: swizzles are safe for masks
|
||||
unsafe { Self::from_int_unchecked(self.to_simd().rotate_elements_left::<OFFSET>()) }
|
||||
unsafe { Self::from_simd_unchecked(self.to_simd().rotate_elements_left::<OFFSET>()) }
|
||||
}
|
||||
|
||||
/// Rotates the mask such that the first `self.len() - OFFSET` elements of the mask move to
|
||||
|
|
@ -544,7 +546,7 @@ where
|
|||
#[must_use = "method returns a new vector and does not mutate the original inputs"]
|
||||
pub fn rotate_elements_right<const OFFSET: usize>(self) -> Self {
|
||||
// Safety: swizzles are safe for masks
|
||||
unsafe { Self::from_int_unchecked(self.to_simd().rotate_elements_right::<OFFSET>()) }
|
||||
unsafe { Self::from_simd_unchecked(self.to_simd().rotate_elements_right::<OFFSET>()) }
|
||||
}
|
||||
|
||||
/// Shifts the mask elements to the left by `OFFSET`, filling in with
|
||||
|
|
@ -554,7 +556,7 @@ where
|
|||
pub fn shift_elements_left<const OFFSET: usize>(self, padding: bool) -> Self {
|
||||
// Safety: swizzles are safe for masks
|
||||
unsafe {
|
||||
Self::from_int_unchecked(self.to_simd().shift_elements_left::<OFFSET>(if padding {
|
||||
Self::from_simd_unchecked(self.to_simd().shift_elements_left::<OFFSET>(if padding {
|
||||
T::TRUE
|
||||
} else {
|
||||
T::FALSE
|
||||
|
|
@ -569,7 +571,7 @@ where
|
|||
pub fn shift_elements_right<const OFFSET: usize>(self, padding: bool) -> Self {
|
||||
// Safety: swizzles are safe for masks
|
||||
unsafe {
|
||||
Self::from_int_unchecked(self.to_simd().shift_elements_right::<OFFSET>(if padding {
|
||||
Self::from_simd_unchecked(self.to_simd().shift_elements_right::<OFFSET>(if padding {
|
||||
T::TRUE
|
||||
} else {
|
||||
T::FALSE
|
||||
|
|
@ -600,7 +602,7 @@ where
|
|||
pub fn interleave(self, other: Self) -> (Self, Self) {
|
||||
let (lo, hi) = self.to_simd().interleave(other.to_simd());
|
||||
// Safety: swizzles are safe for masks
|
||||
unsafe { (Self::from_int_unchecked(lo), Self::from_int_unchecked(hi)) }
|
||||
unsafe { (Self::from_simd_unchecked(lo), Self::from_simd_unchecked(hi)) }
|
||||
}
|
||||
|
||||
/// Deinterleave two masks.
|
||||
|
|
@ -631,8 +633,8 @@ where
|
|||
// Safety: swizzles are safe for masks
|
||||
unsafe {
|
||||
(
|
||||
Self::from_int_unchecked(even),
|
||||
Self::from_int_unchecked(odd),
|
||||
Self::from_simd_unchecked(even),
|
||||
Self::from_simd_unchecked(odd),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -659,7 +661,7 @@ where
|
|||
{
|
||||
// Safety: swizzles are safe for masks
|
||||
unsafe {
|
||||
Mask::<T, M>::from_int_unchecked(self.to_simd().resize::<M>(if value {
|
||||
Mask::<T, M>::from_simd_unchecked(self.to_simd().resize::<M>(if value {
|
||||
T::TRUE
|
||||
} else {
|
||||
T::FALSE
|
||||
|
|
@ -684,6 +686,6 @@ where
|
|||
LaneCount<LEN>: SupportedLaneCount,
|
||||
{
|
||||
// Safety: swizzles are safe for masks
|
||||
unsafe { Mask::<T, LEN>::from_int_unchecked(self.to_simd().extract::<START, LEN>()) }
|
||||
unsafe { Mask::<T, LEN>::from_simd_unchecked(self.to_simd().extract::<START, LEN>()) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -926,7 +926,7 @@ where
|
|||
let mask = unsafe {
|
||||
let tfvec: Simd<<T as SimdElement>::Mask, N> =
|
||||
core::intrinsics::simd::simd_eq(*self, *other);
|
||||
Mask::from_int_unchecked(tfvec)
|
||||
Mask::from_simd_unchecked(tfvec)
|
||||
};
|
||||
|
||||
// Two vectors are equal if all elements are equal when compared elementwise
|
||||
|
|
@ -940,7 +940,7 @@ where
|
|||
let mask = unsafe {
|
||||
let tfvec: Simd<<T as SimdElement>::Mask, N> =
|
||||
core::intrinsics::simd::simd_ne(*self, *other);
|
||||
Mask::from_int_unchecked(tfvec)
|
||||
Mask::from_simd_unchecked(tfvec)
|
||||
};
|
||||
|
||||
// Two vectors are non-equal if any elements are non-equal when compared elementwise
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue