Xref: utzoo comp.lang.c:10597 comp.lang.fortran:714
Path: utzoo!dciem!nrcaer!scs!spl1!laidbak!att!pacbell!ames!umd5!uflorida!novavax!proxftl!bill
From: bill@proxftl.UUCP (T. William Wells)
Newsgroups: comp.lang.c,comp.lang.fortran
Subject: Re: no noalias not negligible - a difference between C and Fortran - long
Message-ID: <249@proxftl.UUCP>
Date: 2 Jun 88 12:59:10 GMT
Article-I.D.: proxftl.249
References: <54080@sun.uucp> <7879@alice.UUCP>
Organization: Proximity Technology, Ft. Lauderdale
Lines: 32
Summary: another minor change

In article <7879@alice.UUCP>, ark@alice.UUCP writes:
>       daxpy(n, da, dx, dy)
>               register double *dx, *dy, da;
>               int n;
>       {
>               register double *dylim = dy + n;
>
>               do *dy += da * *dx++;
>               while (++dy <= dylim);
>       }

If you go this far, you should do this:

	daxpy(n, da, dx, dy)
		register double *dx, *dy, da;
		int n;
	{
		register double *dylim = dy + n;

		do *dy++ += da * *dx++;
		while (dy <= dylim);
	}

[If n is the number of elements in dy, shouldn't the test be a <, not a <=?]

The only difference is moving the ++ from the test condition to the
assignment. For some machines (680?0 ?, VAX ?), this might give slightly
better results because it may be possible to use an addressing mode to
accomplish the increment. Also, the register variables should be ordered dy
and dx instead of dx and dy, this might not make any difference here, but had
these register variables been the second and third, this would have made a
minor difference (on an 80?86, for example).