I've used a similar technique for base-2 logarithms, when I knew the context in which it was used would only require handling powers-of-2 up to 16384: https://github.com/scotts/streamflow/blob/master/streamflow....
edit: Investigating further, this intrinsic was introduced into gcc around 2006, which means I'm not sure it would have been available to me at the time.
For portability reasons, it might be better just using bit tricks and letting the compiler try to optimize it though. Clang and GCC do pretty well here.