Xref: utzoo comp.lang.c:10312 comp.lang.fortran:684 Path: utzoo!attcan!uunet!convex!killer!tness7!bellcore!faline!thumper!ulysses!andante!alice!ark From: ark@alice.UUCP Newsgroups: comp.lang.c,comp.lang.fortran Subject: Re: no noalias not negligible - a difference between C and Fortran - long Message-ID: <7879@alice.UUCP> Date: 22 May 88 03:00:15 GMT References: <54080@sun.uucp> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 47 Posted: Sat May 21 23:00:15 1988 In article <54080@sun.uucp>, dgh@dgh.UUCP writes: > What is to be done? Before writing off C for lacking noalias, try working on the program a little harder. Here is the original program: daxpy(n, da, dx, dy ) double dx[], dy[], da; int n; { int i; i = 0; do { dy[i] = dy[i] + da * dx[i]; } while (i++ < n); } I don't really think there's much here that noalias would help: the object code has to fetch dy[i], add da, multiply by dx[i], and store it in dy[i] and aliasing is irrelevant to each of these operations. Four things could speed it up, though, on many C implementations: 1. Make `i', `n', and `da' into register variables. 2. Use pointers instead of subscripts. 3. Use the += operator to avoid fetching and then storing dy[i]. 4. Replace i++