This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Optimization Question
- To: gcc at gcc dot gnu dot org
- Subject: Re: Optimization Question
- From: David Ronis <ronis at ronispc dot chem dot mcgill dot ca>
- Date: Wed, 28 Jul 1999 16:44:01 -0400
- CC: toon at moene dot indiv dot nluug dot nl
- Reply-to: ronis at onsager dot chem dot mcgill dot ca
Toon Moene just quoted something from the F2K fortran draft, in short
he claims that the standard says:
Expression Allowable alternative form
...
X * Y - X * Z X * ( Y - Z )
...
Expression Nonallowable alternative form
...
X * ( Y - Z ) X * Y - X * Z
That is, in the absence of parenthesis, no standard order is assumed,
and rearrangement is allowed.
Can this be correct? Fortran would essentially have much weaker
precedence rules (which if memory serves me correctly, ISN'T what they
taught in school). What will happen to the tons of legacy code if
this is adopted? To get Toon's 1st example to come out the way the
precedence rules say, you'd have to write:
(X*Y) - (X*Z)
which surely isn't the way most of (us) old-timers wrote code.
I can see lots of places where the rearrangement would be desirable,
and, as has been been pointed out on this thread, places where it
would be a disaster. In the former case, it should be enabled by a
compiler flag (different than -ffast-math I suspect).
Finally, Fortran isn't the only language that would benefit from these
sorts of rearrangements (although it might be the simplest to
implement). If gcc is going to include these (as an option) perhaps
some thought should be given to this aspect as well.
David