popcount support

Jim Wilson jim.wilson@linaro.org
Tue Mar 14 03:59:00 GMT 2017


On Sun, Mar 12, 2017 at 9:41 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On 25 Feb 2017 19:53, Jim Wilson wrote:
>> +/* Return the number of bits set in the input value.  */
>> +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
>> +# define popcount __builtin_popcount
>> +#else
>> +static int
>> +popcount (unsigned char x)
>> ...
>
> gas/config/tc-ia64.c does the same thing, and bfd/elf32-arm.c.
> should we consolidate these in libiberty ?

I noticed the other popcount functions, but 3 didn't seem like a high
enough number to me to justify generalizing the function.  Also note
that the one in the aarch64 sim isn't exactly the same as the others,
as the others take int input and mine takes char input.  So the
aarch64 sim one is faster than the others, as it doesn't need
recursion or a loop.

Jim



More information about the Gdb-patches mailing list