Skip to content

Commit

Permalink
Fix AVX
Browse files Browse the repository at this point in the history
  • Loading branch information
james7132 committed Mar 21, 2024
1 parent dcd96df commit 37f2f41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/block/avx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ pub struct Block(pub(super) __m256d);
impl Block {
#[inline]
pub fn is_empty(self) -> bool {
unsafe { _mm256_testz_pd(self.0, self.0) == 1 }
unsafe {
let value = core::mem::transmute(self);
_mm256_testz_si256(value, value) == 1
}
}

#[inline]
Expand Down Expand Up @@ -81,8 +84,9 @@ impl PartialEq for Block {
#[inline]
fn eq(&self, other: &Self) -> bool {
unsafe {
let eq = _mm256_cmpeq_pd(self.0, other.0);
_mm256_movemask_pd(eq) == !(0i32)
let new = _mm256_xor_pd(self.0, other.0);
let neq = core::mem::transmute(new);
_mm256_testz_si256(neq, neq) == 1
}
}
}
4 changes: 2 additions & 2 deletions src/block/avx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ impl PartialEq for Block {
#[inline]
fn eq(&self, other: &Self) -> bool {
unsafe {
let eq = _mm256_cmpeq_si256(self.0, other.0);
_mm256_movemask_si256(eq) == !(0i32)
let neq = _mm256_xor_si256(self.0, other.0);
_mm256_testz_si256(neq, neq) == 1
}
}
}

0 comments on commit 37f2f41

Please sign in to comment.