Skip to main content

Module pext

Module pext 

Source
Expand description

PEXT-based sliding piece attacks (BMI2 instruction).

When BMI2 is available, the pext instruction replaces the magic multiplication + shift with a single instruction, giving ~2× speedup for sliding piece attacks.

Tables are built at init time using a software PEXT emulation, so they work regardless of CPU support. The hot-path lookup uses hardware PEXT when available via #[target_feature(enable = "bmi2")].

On non-x86_64 the entire module is dead code (the caller in attacks is gated behind #[cfg(target_arch = "x86_64")]).