RFA: Add builtin bitcounting bitops for xstormy16
Richard Henderson
rth@redhat.com
Fri Sep 2 20:12:00 GMT 2005
On Fri, Sep 02, 2005 at 09:22:47AM +0100, Nick Clifton wrote:
> + static const unsigned char __popcount_tab[] =
Why are you replicating this table? It's already present in libgcc2.c,
emitted to its own object file.
> + return __ctzsi2 (y << 16) - 16;
...
> + return __clzsi2 (x) - 16;
See longlong.h. You can simplify these fairly well for fewer bits.
unsigned int __clzhi2 (unsigned int x)
{
if (x > 0xff)
return __clz_tab[x >> 8];
else
return __clz_tab[x] + 8;
}
unsigned int __ctzhi2 (unsigned int x)
{
x = x & -x;
if (x > 0xff)
return 15 - __clz_tab[x >> 8];
else
return 7 - __clz_tab[x];
}
r~
More information about the Gcc-patches
mailing list