At 01:21 PM 10/16/00, Jeff Garzik wrote:
>Bernd Schmidt wrote:
> > diff -x log.build -x .* -dru linux-2.4/drivers/net/tulip/tulip_core.c 
> linux-2.4-fixed/drivers/net/tulip/tulip_core.c
> > --- linux-2.4/drivers/net/tulip/tulip_core.c    Mon Oct 16 13:51:23 2000
> > +++ linux-2.4-fixed/drivers/net/tulip/tulip_core.c      Mon Oct 16 
> 15:40:12 2000
>[...]
> > @@ -944,9 +946,9 @@
> >
> >                 /* Fill the final entry with our physical address. */
> >                 eaddrs = (u16 *)dev->dev_addr;
> > -               *setup_frm++ = *setup_frm++ = eaddrs[0];
> > -               *setup_frm++ = *setup_frm++ = eaddrs[1];
> > -               *setup_frm++ = *setup_frm++ = eaddrs[2];
> > +               *setup_frm++ = eaddrs[0]; *setup_frm++ = eaddrs[0];
> > +               *setup_frm++ = eaddrs[1]; *setup_frm++ = eaddrs[1];
> > +               *setup_frm++ = eaddrs[2]; *setup_frm++ = eaddrs[2];
> >
> >                 spin_lock_irqsave(&tp->lock, flags);
> >

Looking at the above code, I noticed that there are a lot of ++ 
operations.  I rewrote the code as:

     setup_from[0] = setup_from[1] = eaddrs[0];
     setup_from[2] = setup_from[3] = eaddrs[1];
     setup_from[4] = setup_from[5] = eaddrs[2];
     setup_from += 6;

I compiled using "gcc -S -Wall -O2 -fomit-frame-pointer -m486" to generate 
the assembler code.  The old code is 17 instructions long and the new code 
is 11 instructions.  As well as being shorter, simple timing test indicate 
that the new code is significantly quicker.

David

--------------------------------------------------------
David Relson                   Osage Software Systems, Inc.
[EMAIL PROTECTED]       514 W. Keech Ave.
www.osagesoftware.com          Ann Arbor, MI 48103
voice: 734.821.8800            fax: 734.821.8800

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/

Reply via email to