Jakub Jelinek <ja...@redhat.com> wrote:

> On Fri, Nov 20, 2020 at 11:08:41AM +0100, Stefan Kanthak wrote:
>> The construction of the "magic" constants 0x55...55, 0x33...33, 0x0f...0f
>> and 0x01...01 in __popcountSI2 and __popcountDI2 with macros is awkward;
>> these constants can simply be written as ((UWtype) ~0 / 3),
>> ((UWtype) ~0 / 5), ((UWtype) ~0 / 17) and ((UWtype) ~0 / 255)
> 
> (UWtype) ~0 will only work if UWtype is unsigned int,

Hmmm... U*type is but unsigned, and both (__uint128_t) ~0 / 3 as well as
(unsigned long long) ~0 / 3 yield the expected constant 0x55...55 here,
and the other constants of course too.

> don't you really mean ~(UWtype) 0 instead?

This is indeed the better^Wcorrect solution.
Corrected patch attached.

Stefan

Attachment: libgcc2.patch
Description: Binary data

Reply via email to