------- Comment #7 from fxcoudert at gcc dot gnu dot org  2007-09-11 09:55 
-------
(In reply to comment #6)
> Why? more precisely what are the rules behind this yes?

Short answer: the statements are treated independently in the front-end.

When the front-end sees: "nearest(huge(1.0),1.0)", it parses the expression and
then tries to simplify it. huge(1.0) will be replaced by its value, and the
"nearest(xxxxxxx,1.0)" is simplified. (At that point, the front-end detects the
overflow and errors out.)

Normally, the inter-statement optimization is to be done by the middle-end. You
will find that the following code:

  x = 2.
  x = sqrt(x)

you will find that sqrt() is calculated at runtime for -O0, while the two
statements are simplified (and sqrt(2.) is precomputed at compile-time) at -O1.
For NEAREST, the middle-end doesn't perform the simplification because instead
of translating the Fortran statement into C99 functions directly, we use call
the libgfortran function gfortran_nearest_r4(), which the middle-end doesn't
know and can't optimized away. (Doing so is a missed optimization, now filed as
PR33387.)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33296

Reply via email to