How to not fold constants?
Toon Moene
toon@moene.indiv.nluug.nl
Tue Aug 10 15:32:00 GMT 1999
Joern Rennecke wrote:
> > I think an easier (and more obvious IMHO) solution is to have the C
> > frontend "Do The Right Thing", i.e. call build(fold(...)) in case of a
> > static initializer and build(...) otherwise [or is there a snag in there
> > that I'm overlooking ?]
> Yes. There might be integer expressions inside that we want to fold.
Is that true - shouldn't the *frontend* decide how to interpret mixed
mode expressions ? Or is fold-const.c so tied up with C that the
Fortran frontend probably shouldn't use it ?!?
> We also want to fold floating point if this can be done without an
> inexact operation or generating NaNs.
The challenge is to determine that the outcome after folding has a
single correct result, independent of the rounding mode (round to
nearest, round to zero, round up or round down - note, I got the first
one wrong in my original message) applied to the constituent numerical
operations. This condition is necessary, because the compiler cannot
know what the rounding mode _is_, at run time [Off-hand, I'd think that
trying to determine this is equivalent to the halting problem].
Seems like quite a challenge - I wouldn't be surprised if there weren't
_that_ many expressions for which this holds.
--
Toon Moene (toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
GNU Fortran: http://world.std.com/~burley/g77.html
PS: wish you a sunny eclipse :-)
More information about the Gcc
mailing list