Fix mask ops
This commit is contained in:
parent
193cd14b4a
commit
02608d44f7
2 changed files with 5 additions and 5 deletions
|
@ -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<const LANES: usize>(pub(crate) u64)
|
||||
pub struct BitMask<const LANES: usize>(u64)
|
||||
where
|
||||
BitMask<LANES>: 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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue