[PATCH][RFC] Add PAREN_EXPR, make flag_associative_math the default for Fortran
Tobias Schlüter
tobias.schlueter@physik.uni-muenchen.de
Wed Jan 2 17:59:00 GMT 2008
Richard Guenther wrote:
> This adds a middle-end PAREN_EXPR tree code that acts as re-association
> barrier for floating point expressions. This allows to model the Fortran
> semantics that allow re-association for expressions that are not
> explicitly wrapped inside parentheses.
>
> This simple patch (not tested yet) for example preserves a + (b - a)
> if you build with -ffast-math.
>
> function testarray (a, b)
> implicit none
> real*8 :: a, b, testarray
>
> testarray = a + (b - a)
> end
>
> eventually this allows expansion of rounding functions on the tree
> level (those rely on us preserving stuff like (x + 1e-52) - 1e52 and
> not constant fold it).
>
> The way the patch 'works' is that nothing handles (looks through)
> PAREN_EXPR at the moment, so it is a conservative implementation. On
> the RTL level it just relies on the fact that we do not re-associate
> floating point expressions there (we rely on that fact now anyway).
>
> Any thoughts? (Yes, I thought on using a flag on operands or variants
> of the associative tree operators, but these either don't work do not
> model the semantics close enough)
This matches the original intent when INTRINSIC_PARENTHESES were
introduced in the Fortran FE. We also use it to mimic call-by-value
semantics (CALL f((X)) instead of CALL f(X) causes f to receive a
pointer to a copy of X, instead of X itself), but I don't think this
will interfere with your patch.
Thanks for doing this!
Cheers, happy new year all,
- Tobi
More information about the Fortran
mailing list