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;
|
use crate::LanesAtMost32;
|
||||||
|
|
||||||
/// A mask where each lane is represented by a single bit.
|
/// 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)]
|
#[repr(transparent)]
|
||||||
pub struct BitMask<const LANES: usize>(pub(crate) u64)
|
pub struct BitMask<const LANES: usize>(u64)
|
||||||
where
|
where
|
||||||
BitMask<LANES>: LanesAtMost32;
|
BitMask<LANES>: LanesAtMost32;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ where
|
||||||
/// Construct a mask by setting all lanes to the given value.
|
/// Construct a mask by setting all lanes to the given value.
|
||||||
pub fn splat(value: bool) -> Self {
|
pub fn splat(value: bool) -> Self {
|
||||||
if value {
|
if value {
|
||||||
Self(u64::MAX)
|
Self(u64::MAX >> (64 - LANES))
|
||||||
} else {
|
} else {
|
||||||
Self(u64::MIN)
|
Self(u64::MIN)
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,12 +131,12 @@ where
|
||||||
/// Returns true if any lane is set, or false otherwise.
|
/// Returns true if any lane is set, or false otherwise.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn any(self) -> bool {
|
pub fn any(self) -> bool {
|
||||||
self.0 != 0
|
self != Self::splat(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if all lanes are set, or false otherwise.
|
/// Returns true if all lanes are set, or false otherwise.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn all(self) -> bool {
|
pub fn all(self) -> bool {
|
||||||
self.0 == (!0) >> (64 - LANES)
|
self == Self::splat(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue