diff --git a/crates/core_simd/src/masks/bitmask.rs b/crates/core_simd/src/masks/bitmask.rs index 1d25db46742..b4d1b6d9557 100644 --- a/crates/core_simd/src/masks/bitmask.rs +++ b/crates/core_simd/src/masks/bitmask.rs @@ -1,9 +1,9 @@ use crate::LanesAtMost32; /// A mask where each lane is represented by a single bit. -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, PartialOrd, PartialEq, Ord, Eq, Hash)] #[repr(transparent)] -pub struct BitMask(pub(crate) u64) +pub struct BitMask(u64) where BitMask: LanesAtMost32; @@ -14,7 +14,7 @@ where /// Construct a mask by setting all lanes to the given value. pub fn splat(value: bool) -> Self { if value { - Self(u64::MAX) + Self(u64::MAX >> (64 - LANES)) } else { Self(u64::MIN) } diff --git a/crates/core_simd/src/reduction.rs b/crates/core_simd/src/reduction.rs index 0c6d91a2bef..d314cc737ed 100644 --- a/crates/core_simd/src/reduction.rs +++ b/crates/core_simd/src/reduction.rs @@ -131,12 +131,12 @@ where /// Returns true if any lane is set, or false otherwise. #[inline] pub fn any(self) -> bool { - self.0 != 0 + self != Self::splat(false) } /// Returns true if all lanes are set, or false otherwise. #[inline] pub fn all(self) -> bool { - self.0 == (!0) >> (64 - LANES) + self == Self::splat(true) } }