Subject: Re: PPS diffs, round #3
To: Jonathan Stone <jonathan@dsg.stanford.edu>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: tech-kern
Date: 04/22/1998 13:53:23
On Tue, 21 Apr 1998 22:37:43 -0700 (PDT) 
 Jonathan Stone <jonathan@DSG.Stanford.EDU> wrote:

 > But because gcc can't do good alias analysis, it cant tell you didn't
 > change sc.  So you have to recompute the pointer into the softc each time.
 > It's a micro-optimization, but it can go if you really want.

I disagree.  On my Alpha, a simple test case (appended below) produces
fewer instructions and less stack usage when the local variable is not
used.

Also, if you want to tell GCC that the softc pointer isn't changing,
you can use:

	struct com_softc * const sc = arg;

Jason R. Thorpe                                       thorpej@nas.nasa.gov
NASA Ames Research Center                            Home: +1 408 866 1912
NAS: M/S 258-5                                       Work: +1 650 604 0935
Moffett Field, CA 94035                             Pager: +1 415 428 6939

#include <sys/types.h>
#include <sys/time.h>
#include <sys/device.h>

struct foo_softc {
	struct device sc_dev;
	struct timeval sc_tv;
};

extern void microtime __P((struct timeval *tv));
extern void hardpps __P((struct timeval *, u_long));

void
foo_intr(arg)
	void *arg;
{
	struct foo_softc *sc = arg;
#ifdef USE_LOCAL
	struct timeval tv;

	microtime(&tv);
	sc->sc_tv = tv;
	hardpps(&tv, tv.tv_usec);
#else
	microtime(&sc->sc_tv);
	hardpps(&sc->sc_tv, sc->sc_tv.tv_usec);
#endif
}