This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: streamline libgcc clz, ctz, parity
- From: Falk Hueffner <falk dot hueffner at student dot uni-tuebingen dot de>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 01 Feb 2003 22:29:32 +0100
- Subject: Re: streamline libgcc clz, ctz, parity
- References: <20030201130503.A31733@redhat.com>
Richard Henderson <rth@redhat.com> writes:
> Finally, on most targets getting the (pic) address of __popcount_tab
> is more expensive than continuing to simplify the parity with
> shifts.
If we don't want to use a table, how about this cute trick:
unsigned par(unsigned x)
{
unsigned long nx = x;
nx ^= nx >> 16;
nx ^= nx >> 8;
nx ^= nx >> 4;
nx &= 0xf;
return (0x6996 >> nx) & 1;
}
(based on the same idea as Roger's recent switch improvement).
--
Falk