Xref: utzoo comp.lang.c:10480 comp.lang.fortran:696 Path: utzoo!attcan!uunet!husc6!purdue!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c,comp.lang.fortran Subject: Re: no noalias not negligible: more red herrings, conclusion unchanged Message-ID: <11711@mimsy.UUCP> Date: 28 May 88 18:37:40 GMT References: <54713@sun.uucp> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 34 In article <54713@sun.uucp> dgh%dgh@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@mimsy.umd.edu Path: uunet!mimsy!chris