4 ms·
It's worth noting that modern x86 CPUs have specialized extensions for bit manipulation. Furthermore C23 added stdbit.h that has some operations for bit manipul
by zokier 2y ago
It's worth noting that modern x86 CPUs have specialized extensions for bit manipulation. Furthermore C23 added stdbit.h that has some operations for bit manipulation
https://en.wikipedia.org/wiki/X86_Bit_manipulation_instruction_set https://en.wikipedia.org/wiki/X86_Bit_manipulation_instructi...
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Modern%20Bit%20Utilities.html https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Modern%...
- exDM69 2y agoAbsolutely, look into your standard library, CPU built-ins and intrinsics first. However, these tricks are not useless even on modern CPUs. There are scalar instructions for a lot of this stuff, but if you are working with SIMD, several of them are not available. Recently I wrote bit interleaving stuff with Morton codes. Maybe the scalar instruction would be faster in isolation but I already have my data in SSE registers for other arithmetic so in total it was probably faster. I used the code in this article as a basis.
- overanalytcl 2y agoThe last link doesn't work.