no noalias not negligible: more red herrings, conclusion unchanged
Chris Torek
chris at mimsy.UUCP
Sun May 29 04:37:40 AEST 1988
In article <54713 at sun.uucp> dgh%dgh at Sun.COM (David Hough) writes:
>... the following versions of ROLLED source; the first results in unrolled
>object code; the second and most other equivalent ones do not:
[Some text deleted. First version:]
> i = 0;
> do {
> dy[i] = dy[i] + da * dx[i];
> i++;
> } while (i < n);
[Second:]
> i = 0;
> do {
> dy[i] = dy[i] + da * dx[i];
> } while (i++ < n);
This illustrates a very important point. These two loops are *not*
equivalent! If n is 2, the first loop executes twice (as it should);
the second executes three times. So remember:
Make it right before you make it fast, and do try not to break it
when you make it fast. :-)
(I still do not understand the insistence on avoiding the form
do {
dy[i] += da * dx[i];
} while (++i < n);
which is much easier to read, and remains correct.)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list