Filled in missing methods on the fall-back non-SIMD code.
This commit is contained in:
parent
b09f9684d1
commit
874b07df02
|
@ -680,8 +680,8 @@ mod x86_64_sse {
|
|||
|
||||
/// Returns whether all four bools are false.
|
||||
///
|
||||
/// This is the `OR` operation on all the contained bools. If even
|
||||
/// one bool is true, this returns true.
|
||||
/// This is the `NOT` operation on the result of `OR`ing all the
|
||||
/// contained bools. If even one bool is true, this returns false.
|
||||
#[inline(always)]
|
||||
pub fn is_all_false(&self) -> bool {
|
||||
let a = unsafe { *(&self.data as *const __m128 as *const u128) };
|
||||
|
@ -1269,21 +1269,25 @@ mod fallback {
|
|||
det
|
||||
}
|
||||
|
||||
/// Essentially a tuple of four bools, which will use SIMD operations
|
||||
/// where possible on a platform.
|
||||
#[cfg(feature = "simd_perf")]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct Bool4 {
|
||||
data: bool32fx4,
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "simd_perf"))]
|
||||
/// Essentially a tuple of four bools.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct Bool4 {
|
||||
data: [bool; 4],
|
||||
}
|
||||
|
||||
impl Bool4 {
|
||||
#[inline(always)]
|
||||
pub fn new(a: bool, b: bool, c: bool, d: bool) -> Bool4 {
|
||||
Bool4 { data: [a, b, c, d] }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn new_false() -> Bool4 {
|
||||
Bool4 {
|
||||
data: [false, false, false, false],
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the value of the nth element.
|
||||
#[inline(always)]
|
||||
pub fn get_n(self, n: usize) -> bool {
|
||||
|
@ -1318,6 +1322,15 @@ mod fallback {
|
|||
self.get_n(3)
|
||||
}
|
||||
|
||||
/// Returns whether all four bools are false.
|
||||
///
|
||||
/// This is the `NOT` operation on the result of `OR`ing all the
|
||||
/// contained bools. If even one bool is true, this returns false.
|
||||
#[inline(always)]
|
||||
pub fn is_all_false(&self) -> bool {
|
||||
!(self.data[0] | self.data[1] | self.data[2] | self.data[3])
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn to_bitmask(self) -> u8 {
|
||||
(self.get_0() as u8)
|
||||
|
@ -1598,4 +1611,10 @@ mod tests {
|
|||
|
||||
assert_eq!(r, 0b00001010);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bool4_is_all_false() {
|
||||
assert_eq!(true, Bool4::new(false, false, false, false).is_all_false());
|
||||
assert_eq!(false, Bool4::new(false, false, true, false).is_all_false());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user