Xref: utzoo comp.lang.c:10255 comp.lang.fortran:676 Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!oberon!cit-vax!elroy!ames!ncar!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c,comp.lang.fortran Subject: Re: no noalias not negligible Message-ID: <11609@mimsy.UUCP> Date: 21 May 88 04:38:02 GMT References: <54080@sun.uucp> <11608@mimsy.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 32 One I forgot: inline expansion. The latest GCC compilers have inline functions, and `inline' is easy to add to a C compiler (although the resulting langauge is not C). daxpy is certainly short enough to write in line: inline void daxpy(int n, double a, double *x, double *y) { int i; for (i = 0; i < n; i++) y[i] += a * x[i]; } or (as short as I can make it :-) ) inline void daxpy(int n, double a, double *x, double *y) { while (--n >= 0) *y++ += a * *x++; } To stick to C proper, although it introduces possible name collisions, and makes daxpy() not an expression, #define daxpy(n, a, x, y) do { \ register int daxpy_n = n; \ register double daxpy_a = a, *daxpy_x = x, *daxpy_y = y; \ while (--daxpy_n >= 0) *daxpy_y++ += a * *daxpy_x++; \ } while (0) The resulting expansion (either from the cleaner but nonstandard `inline void' versions, or the macro version) will likely not only run faster (no subroutine call overhead) but also be in a place where the optimiser can see whether there are aliasing problems. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris