smart compilers
John Gilmore
gnu at sun.uucp
Wed Dec 26 16:52:49 AEST 1984
> James Giles says:
> My first version was wrong. But 'Y' is a loop invariant, the
> correct optimization is:
>
> IF (Y.GT.0) THEN
> TEMP=SQRT(Y)
> DO 100 I=1,10
> X(I)=TEMP
> 100 CONTINUE
> ENDIF
>
> This has the advantage of not going through the loop at all if the
> assignments would all have been skipped. All these examples show the point
> I originally made: these optimizations are unsafe unless you have a REALLY
> GOOD data flow analyzer.
You're absolutely right! Had you had a good data flow analyzer, it
would have detected that your optimization had changed the value of 'I'
on exit from this piece of code.
More information about the Comp.unix.wizards
mailing list