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]

Re: [PATCH] Add ffs() to libiberty


On Sat, Jul 14, 2001 at 06:01:24PM -0400, DJ Delorie wrote:
> > >   valu = valu & -valu;
> 
> That isn't really portable, especially since valu is unsigned.

Yes it is portable.

> > >   if (valu & 0xf0)
> > >     bit += 4;
> 
> Why not "if (!(valu & 0x0f))" instead?  Then it wouldn't matter if
> there was more than one bit set.  Ditto others.

Um, no, think about it some more.  We're trading the need
for a single bit set for the need to do a shift as well
as the addition.


r~


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