How can I count the number of leading zeros in a 128-bit integer (uint128_t
) efficiently?
I know GCC's built-in functions:
__builtin_clz
,__builtin_clzl
,__builtin_clzll
__builtin_ffs
,__builtin_ffsl
,__builtin_ffsll
However, these functions only work with 32- and 64-bit integers.
I also found some SSE instructions:
__lzcnt16
,__lzcnt
,__lzcnt64
As you may guess, these only work with 16-, 32- and 64-bit integers.
Is there any similar, efficient built-in functionality for 128-bit integers?