▲ | mananaysiempre 4 days ago | |||||||
The POSIX name for the function is clz() [the C23 name is stdc_leading_zeros(), because that's how the committee names things now, while the GCC intrinsic is __builtin_clz()]. The name of the x86 instruction, on the other hand, is BSR (80386+) or LZCNT (Nehalem+, K10+) depending on what semantics you want for zero inputs (keep in mind that early implementations of BSF/BSR are very slow and take time proportional to the output value). The compiled code uses BSR. (All of these are specified slightly differently, take care if you plan to actually use them.) | ||||||||
▲ | unwind 4 days ago | parent [-] | |||||||
Got it, thanks. I suck at x86, even more than I thought. :/ Edit: it's CLZ on Arm [1], probably what I was looking for. [1]: https://developer.arm.com/documentation/100069/0610/A32-and-... | ||||||||
|