This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: Add support for Renesas RX architecture to GCC (take 2)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 15 Oct 2009 13:01:17 +0000 (UTC)
- Subject: Re: RFA: Add support for Renesas RX architecture to GCC (take 2)
- References: <m3r5tefinf.fsf@redhat.com> <4ACFB188.2070709@redhat.com> <4AD6D9A3.3080209@redhat.com>
On Thu, 15 Oct 2009, Nick Clifton wrote:
> > > + static unsigned int
> > > + bit_count (unsigned int x)
> > > + {
> > > + const unsigned int m1 = 0x55555555;
> > > + const unsigned int m2 = 0x33333333;
> > > + const unsigned int m4 = 0x0f0f0f0f;
> > > +
> > > + x -= (x >> 1) & m1;
> > > + x = (x & m2) + ((x >> 2) & m2);
> > > + x = (x + (x >> 4)) & m4;
> > > + x += x >> 8;
> > > +
> > > + return (x + (x >> 16)) & 0x3f;
> >
> > We should probably have this function moved to somewhere generic. We have
> > several places within gcc that we compute a population count. Search for
> > popcount within the toplevel gcc sources.
>
> Could I submit that as a separate patch ? I would like to keep this one
> RX specific.
If we create a generic population count function, it should use
__builtin_popcount (or __builtin_popcountl for a count function of
unsigned long) when built with GCC 3.4 or later (and should probably be
inlined in a header in that case).
--
Joseph S. Myers
joseph@codesourcery.com