3 ms·
Using 64bit value for the shift solution would allow still more tight scalar code, dunno for vectorization. pub fn phf_shift64(x: u32) { ((0x714258
by zokier 4y ago
Using 64bit value for the shift solution would allow still more tight scalar code, dunno for vectorization.
pub fn phf_shift64(x: u32) {
((0x714258693u64 >> (x*4)) & 0b1111) as u8
}
- kzrdude 4y agoThis particular code will have a bounds check for x * 4 and panic if it's too large, thus inhibiting vectorization in most cases. Just as a tidbit, to dig deeper into Rust. How can I provide some quick evidence for this? Well there's a method called u64::unchecked_shr that acts as contrasting evidence.