Re: [PATCH] 2.4.21-rc1 pointless IDE noise reduction

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Fri Apr 25 2003 - 13:30:51 EST


On Fri, 25 Apr 2003, Bill Davidsen wrote:

> On Thu, 24 Apr 2003, Richard B. Johnson wrote:
>
>
> > > Two alternatives:
> > >
> > > (a) !!(x & 0x400)
> > >
> > > (b) (x & 0x400) >> 10
> > >
> >
> > I meant return ((foo & MASK) && 1);
> >
> > Try it, you'll like it! No shifts, no jumps.
>
> Sorry, I still find !!(foo & MASK) easier to read, because !! is only used
> to convert to boolean. Sort of a "boolean cast" in effect. It jumps out at
> you what is intended.
>
> Anyway, a matter of taste, both generate jumpless code.
Yes, you win. This looks good, both as code and as op-codes on
Intel...
#include <stdio.h>
int main()
{
    int i;
    int mask = 0x40;
    for(i=0; i< 0x1000; i++)
        printf("%08x\n", !!(i & mask));
}

You need to actually change something, hense the for() loop. Otherwise
gcc just optimizes everything to a 1!

Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Apr 30 2003 - 22:00:22 EST