This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: Add support for Renesas RX architecture to GCC (take 2)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]