On Fri, Feb 27, 2026 at 01:49:08PM +0100, Richard Biener wrote:
> > Therefore clzl(256) should deliver 8 because 1<<8 is 256. On some platforms
> > clzl delivers 55 like you pointed out, but that is of no use to use.
>
> No, clzl (256ul) should be 55, because 1 << (64 - 55 - 1) is 256.
Or 23 for 32-bit unsigned long.
> > So what would be the best way to resolve this?
>
> As said, simply do
>
> static size_t
> next_power_of_two (size_t size)
> {
> return (size_t)1 << (__SIZEOF_LONG_LONG__ * 8 - __builtin_clzll (size - 1));
s/8/__CHAR_BIT__/
Jakub