Skip to content

Commit 02608d4

Browse files
committed
Fix mask ops
1 parent 193cd14 commit 02608d4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

crates/core_simd/src/masks/bitmask.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::LanesAtMost32;
22

33
/// A mask where each lane is represented by a single bit.
4-
#[derive(Copy, Clone, Debug)]
4+
#[derive(Copy, Clone, Debug, PartialOrd, PartialEq, Ord, Eq, Hash)]
55
#[repr(transparent)]
6-
pub struct BitMask<const LANES: usize>(pub(crate) u64)
6+
pub struct BitMask<const LANES: usize>(u64)
77
where
88
BitMask<LANES>: LanesAtMost32;
99

@@ -14,7 +14,7 @@ where
1414
/// Construct a mask by setting all lanes to the given value.
1515
pub fn splat(value: bool) -> Self {
1616
if value {
17-
Self(u64::MAX)
17+
Self(u64::MAX >> (64 - LANES))
1818
} else {
1919
Self(u64::MIN)
2020
}

crates/core_simd/src/reduction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ where
131131
/// Returns true if any lane is set, or false otherwise.
132132
#[inline]
133133
pub fn any(self) -> bool {
134-
self.0 != 0
134+
self != Self::splat(false)
135135
}
136136

137137
/// Returns true if all lanes are set, or false otherwise.
138138
#[inline]
139139
pub fn all(self) -> bool {
140-
self.0 == (!0) >> (64 - LANES)
140+
self == Self::splat(true)
141141
}
142142
}

0 commit comments

Comments
 (0)