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:58:10PM -0400, DJ Delorie wrote:
> Only to two-s compliment machines.  Not on ones-complement or
> separate-sign machines.

Hah.  Like _any_ of the rest of the compiler is going to
work on a ones complement.  Ignore them.

> And mixing negation and unsigned just feels
> wrong to me (it's at least an overflow condition).

On the contrary, it's well defined.

> I don't see it.  Compare:
> 
>    if (valu & 0xf0)
>      bit += 4;
> 
>    if (!(valu & 0x0f))
>      bit += 4;
> 
> Where is the extra shift/add coming into play?

In the _subsequent_ tests.  The (valu & 0xCC) and (valu & 0xAA)
tests aren't valid unless there is exactly one bit set.

Run through the rest of the funciton with 0xA0 and 0x10 and see
what difference it makes.


r~


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