in reply to Most Significant Set Bit

Many CPUs have ways of counting leading zeroes. In gcc, these can be access using __builtin_clz, __builtin_clzl and __builtin_clzll.

So you could use Inline::C to run C code that uses that.

Or you could use XS or FFI::Platypus to access a C library that provides a function that uses that.