Re: 'Call clzl check' breaks cross compilation (was: PATCH 13/22] Coarray caf_shmem final patch set)

Jakub Jelinek <[email protected]>
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.