Re: Performance tweaks

From: Andrew Morton (morton@nortelnetworks.com)
Date: Sat Feb 26 2000 - 01:54:30 EST


Horst von Brand wrote:
>
> Mitchell Blank Jr <mitch@sfgoth.com> said:
> > Andrew Morton wrote:
> > > For uniprocessors this:
> > >
> > > const int cpu = smp_processor_id();
> > > if (dev->xmit_lock_owner != cpu) {
> > >
> > > generates faster code than this:
> > >
> > > int cpu = smp_processor_id();
> > > if (dev->xmit_lock_owner != cpu) {
>
> > That's really odd, I would have assumed that gcc would have optomized
> > the variable away, but your experiment indicates otherwise.
>
> What version of gcc?

This week's.

> Optimizations have been improving steadily. It is
> better to fix the compiler than to mess up the source to get it do do what
> it should do. The gcc folks _are_ receptive to reports.

Agreed. I'll mention it on the gcc list. The compiler could always get
better, but we always give it a helping hand, don't we? Particularly
with manual CSE - it's everywhere.

Regarding "mess up the source": beg to differ. The use of 'const'
actually improves the source. A lot. Contracts, communication of
designer intent, etc. Religious issue - I stop here.

[ It doesn't mess up the source as much as 'asm', and why do we use that
in places where C would work? :) ]

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



This archive was generated by hypermail 2b29 : Tue Feb 29 2000 - 21:00:15 EST