On ARM Cortex-M3, for example, CLZ instruction is present, it counts leading zeros of an 32 bit integer. If integer is zero, result is 32.
In gcc, on the other hand, I can use a __builtin_clz function. However, according to gcc documentation:
Built-in Function: int __builtin_clz (unsigned int x).
Returns the number of leading 0-bits in x, starting at the most significant bit position. If x is 0, the result is undefined.
So if using this builtin I should manually handle zero? Or is it guaranted to be compiled to CLZ instruction if such an instruction is present on target machine?
Quotes from gcc documentation are highly appritiated!