[PATCH] Add PAREN_EXPR
Richard Guenther
rguenther@suse.de
Wed Feb 20 15:45:00 GMT 2008
On Wed, 20 Feb 2008, Tim Prince wrote:
> Richard Guenther wrote:
> > On Tue, 19 Feb 2008, Tobias Burnus wrote:
> >
> >> FX wrote:
> >>>> * trans-expr.c (gfc_conv_expr_op): Expand INTRINSIC_PARENTHESES
> >>>> as unary PAREN_EXPR for real and complex typed expressions.
> >>>> * options.c (gfc_init_options): Enable flag_associative_math if
> >>>> it isn't disabled automatically.
> >>>>
> >>>> * gfortran.dg/reassoc_1.f90: New testcase.
> >>>> * gfortran.dg/reassoc_2.f90: Likewise.
> >>>>
> >>> Fortran part is OK. Thanks!
> >>>
> >> Thanks also from me. Is it possible to add a flag for disabling the
> >> PAREN_EXPR? I'm sure some users want to have this to gain some speed. (For
> >> a/(b*c) the () are often only used because it is easier to read than a/b/c;
> >> for such programs it might be useful to be able to disable it.)
> >>
>
> How would the version with 2 divisions become faster than the original?
> It seems more likely that the original version would have been written for
> improved speed, or to avoid inconsistencies according to whether the
> version with 2 divides is optimized.
Yeah. It's probably more for things like a-(b+c) where it doesn't matter
to use the equivalent a-b-c. Or other cases where parens are added
for syntactic reasons rather than to guard against re-association.
That said - somebody with decent knowledge of the Fortran standard
(and its user community) should decide what to do by default and
what to do with -ffast-math and if Fortran wants an extra flag
that says it wants full IEEE compatibility.
It might for example be ok to by default do the equivalent of
-fno-signed-zeros -fno-trapping-math -fassociative-math
I'm not sure about -ffinite-math-only (though it was said Fortran
doesn't know about NaNs or Infs), as that has the bad side-effect
of also unconditionally folding of isnan() etc. Still without
that flag we do not simplify x - x to 0. or 0. * x to 0., so
re-association is only useful to combine constants then.
(IMHO we might want to split -ffinite-math-only into one flag
affecting arithmetic simplification and one flag folding the
FP predicates and replacing unordered compares by ordered ones.)
Richard.
More information about the Fortran
mailing list