James Giles wrote:
>
> Walt Brainerd <[log in to unmask]>wrote:
> ...
> >I agree that the standard doesn't have the same words about
> >multi-statement
> >optimization, but we all know it "must be allowed". Otherwise, a
> >compiler
> >would not be free to move a statement out from the following loop (no
> >aliasing
> >among x, t, y and a, of course):
> >
> >do i = 1, n
> > x = cos (6.5*t) + y
> > a(i) = a(i) + x
> >end do
>
> Well, the "as-if" rule clearly applies. I doesn't matter to the meaning
> of the above whether X is computed once before the loop executes
> or whether you compute the expression every time. So, the result
> is indistinguishable (except for speed). It is generally held that, in
> such cases, the optimization is valid regardless of the apparent
> constraints of the language standard.
I forgot to comment on this part. This is the way things work,
I think, and so certainly agree with this. It doesn't seem to square
with what Keith reported and (with my faulty understanding) doesn't
seem to square with the stuff from James that I quoted in the previous
message.
Keith says, however, that you can usually tell that such a
transformation
has been performed. It seems to me that the only "legal" test should be
performed by looking at the output of the program, not by looking at
code,
for example.
--
Walt Brainerd [log in to unmask]
Unicomp, Inc. +1-520-298-7212 298-7074 (fax)
7660 E. Broadway, Suite 308 888-330-6060
Tucson, AZ 85710 USA http://www.uni-comp.com
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|