Fix mask ops

This commit is contained in:
Caleb Zulawski 2021-03-11 00:05:20 -05:00
parent 193cd14b4a
commit 02608d44f7
2 changed files with 5 additions and 5 deletions

View file

@ -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)
}

View file

@ -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)
}
}