Skip to content

Commit

Permalink
Add slow_pext cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
primenumber committed May 4, 2024
1 parent 6ad30e1 commit c1c3e48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/engine/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ pub trait BitManip {
}

impl BitManip for u64 {
#[cfg(target_feature = "bmi2")]
#[cfg(all(target_feature = "bmi2", not(slow_pext)))]
fn pext(&self, mask: u64) -> u64 {
unsafe { _pext_u64(*self, mask) }
}

#[cfg(not(target_feature = "bmi2"))]
#[cfg(not(all(target_feature = "bmi2", not(slow_pext))))]
fn pext(&self, mut mask: u64) -> u64 {
let mut x = *self;
x = x & mask;
Expand Down
12 changes: 6 additions & 6 deletions src/engine/last_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ impl LastCache {
}
}

#[cfg(target_feature = "bmi2")]
#[cfg(all(target_feature = "bmi2", not(slow_pext)))]
fn get_col_bits(bits: u64, mask: u64, _col: usize) -> u64 {
bits.pext(mask)
}

#[cfg(not(target_feature = "bmi2"))]
#[cfg(not(all(target_feature = "bmi2", not(slow_pext))))]
fn get_col_bits(mut bits: u64, mask: u64, col: usize) -> u64 {
bits &= mask;
((bits >> col).wrapping_mul(0x0002_0408_1020_4081) >> 49) & 0xff
}

#[cfg(target_feature = "bmi2")]
#[cfg(all(target_feature = "bmi2", not(slow_pext)))]
fn get_diag1_bits(bits: u64, mask: u64, _row: usize, _col: usize) -> u64 {
bits.pext(mask)
}

#[cfg(not(target_feature = "bmi2"))]
#[cfg(not(all(target_feature = "bmi2", not(slow_pext))))]
fn get_diag1_bits(mut bits: u64, mask: u64, row: usize, col: usize) -> u64 {
bits &= mask;
let width = if row >= col {
Expand All @@ -92,12 +92,12 @@ impl LastCache {
(bits.wrapping_mul(0x0101_0101_0101_0101) >> 56) & ((1 << width) - 1)
}

#[cfg(target_feature = "bmi2")]
#[cfg(all(target_feature = "bmi2", not(slow_pext)))]
fn get_diag2_bits(bits: u64, mask: u64, _row: usize, _col: usize) -> u64 {
bits.pext(mask)
}

#[cfg(not(target_feature = "bmi2"))]
#[cfg(not(all(target_feature = "bmi2", not(slow_pext))))]
fn get_diag2_bits(mut bits: u64, mask: u64, row: usize, col: usize) -> u64 {
bits &= mask;
let width = if row + col >= 7 {
Expand Down

0 comments on commit c1c3e48

Please sign in to comment.