Which processors support __builtin_clz?
10:09 06 Oct 2020

Is there a reference somewhere that tells me which processors support 'clz' natively? Can I assume almost all desktops, servers, and mobile phones will support it?

I tried using __builtin_ffs instead since it's lack of undefined behavior at 0 saved me instructions in performance critical code but in benchmarks it was 10x slower than __builtin_clz, which makes it think it isn't hardware supported, even though __has_builtin(__builtin_ffs) is returning true. Need to run on any processor efficiently.

How can I be sure that clz won't have the same issue on some hardware?

c++ clang built-in