Commit 72bd130e by Tobias Burnus Committed by Tobias Burnus

re PR fortran/35259 (-fassociative-math not enabled by default; No option to…

re PR fortran/35259 (-fassociative-math not enabled by default;  No option to associate with PAREN_EXPRs)

2010-02-21  Tobias Burnus  <burnus@net-b.de>

        PR fortran/35259
        * doc/invoke.texi (-fassociative-math): Document that this
        option is automatically enabled for Fortran.

2010-02-21  Tobias Burnus  <burnus@net-b.de>

        PR fortran/35259
        * gfortran.h (gfc_option_t): New flag -fprotect-parens.
        * lang.opt: Ditto.
        * option.c (gfc_init_options,gfc_handle_option): Ditto.
        * trans-expr.c (gfc_conv_expr_op): Use the flag.
        * invoke.texi: Document new -fno-protect-parens flag.

2010-02-21  Tobias Burnus  <burnus@net-b.de>

        PR fortran/35259
        * gfortran.dg/reassoc_5.f90: New test.

From-SVN: r156937
parent c76dc9b0
2010-02-21 Tobias Burnus <burnus@net-b.de>
PR fortran/35259
* doc/invoke.texi (-fassociative-math): Document that this
option is automatically enabled for Fortran.
2010-02-20 David S. Miller <davem@davemloft.net>
* configure.ac: Test if linker and assembler properly support
......
......@@ -7541,7 +7541,9 @@ thus cannot be used on a code which relies on rounding behavior like
and thus may not be used when ordered comparisons are required.
This option requires that both @option{-fno-signed-zeros} and
@option{-fno-trapping-math} be in effect. Moreover, it doesn't make
much sense with @option{-frounding-math}.
much sense with @option{-frounding-math}. For Fortran the option
is automatically enabled when both @option{-fno-signed-zeros} and
@option{-fno-trapping-math} are in effect.
The default is @option{-fno-associative-math}.
......
2010-02-21 Tobias Burnus <burnus@net-b.de>
PR fortran/35259
* gfortran.h (gfc_option_t): New flag -fprotect-parens.
* lang.opt: Ditto.
* option.c (gfc_init_options,gfc_handle_option): Ditto.
* trans-expr.c (gfc_conv_expr_op): Use the flag.
* invoke.texi: Document new -fno-protect-parens flag.
2010-02-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/36932
......
......@@ -2150,6 +2150,7 @@ typedef struct
char flag_init_character_value;
int flag_align_commons;
int flag_whole_file;
int flag_protect_parens;
int fpe;
int rtcheck;
......
......@@ -171,7 +171,8 @@ and warnings}.
-fpack-derived -frepack-arrays -fshort-enums -fexternal-blas @gol
-fblas-matmul-limit=@var{n} -frecursive -finit-local-zero @gol
-finit-integer=@var{n} -finit-real=@var{<zero|inf|-inf|nan|snan>} @gol
-finit-logical=@var{<true|false>} -finit-character=@var{n} -fno-align-commons}
-finit-logical=@var{<true|false>} -finit-character=@var{n} @gol
-fno-align-commons -fno-protect-parens}
@end table
@menu
......@@ -1410,6 +1411,16 @@ consistent data types everywhere, this padding can cause trouble, and
same form of this option should be used for all files that share a COMMON block.
To avoid potential alignment issues in COMMON blocks, it is recommended to order
objects from largests to smallest.
@item -fno-protect-parens
@opindex @code{fno-protect-parens}
@cindex re-association of parenthesed expressions
By default the parentheses in expression are honored for all optimization
levels such that the compiler does not do any re-association. Using
@option{-fno-protect-parens} allows the compiler to reorder REAL and
COMPLEX expressions to produce faster code. Note that for the re-association
optimization @option{-fno-signed-zeros} and @option{-fno-trapping-math}
need to be in effect.
@end table
@xref{Code Gen Options,,Options for Code Generation Conventions,
......
......@@ -324,6 +324,10 @@ fpreprocessed
Fortran
; Documented in C
fprotect-parens
Fortran
Protect parentheses in expressions
frange-check
Fortran
Enable range checking during compilation
......
......@@ -125,6 +125,7 @@ gfc_init_options (unsigned int argc, const char **argv)
gfc_option.flag_init_character = GFC_INIT_CHARACTER_OFF;
gfc_option.flag_init_character_value = (char)0;
gfc_option.flag_align_commons = 1;
gfc_option.flag_protect_parens = 1;
gfc_option.fpe = 0;
gfc_option.rtcheck = 0;
......@@ -921,6 +922,10 @@ gfc_handle_option (size_t scode, const char *arg, int value)
gfc_option.flag_align_commons = value;
break;
case OPT_fprotect_parens:
gfc_option.flag_protect_parens = value;
break;
case OPT_fcheck_:
gfc_handle_runtime_check_option (arg);
break;
......
......@@ -1222,8 +1222,9 @@ gfc_conv_expr_op (gfc_se * se, gfc_expr * expr)
switch (expr->value.op.op)
{
case INTRINSIC_PARENTHESES:
if (expr->ts.type == BT_REAL
|| expr->ts.type == BT_COMPLEX)
if ((expr->ts.type == BT_REAL
|| expr->ts.type == BT_COMPLEX)
&& gfc_option.flag_protect_parens)
{
gfc_conv_unary_op (PAREN_EXPR, se, expr);
gcc_assert (FLOAT_TYPE_P (TREE_TYPE (se->expr)));
......
2010-02-21 Tobias Burnus <burnus@net-b.de>
PR fortran/35259
* gfortran.dg/reassoc_5.f90: New test.
2010-02-20 Uros Bizjak <ubizjak@gmail.com>
PR target/43067
......
! { dg-do compile }
! { dg-options "-O3 -ffast-math -fdump-tree-optimized -fno-protect-parens" }
!
! PR fortran/35259
! Test for -fno-protect-parens
!
function test(b)
real a
a = (b + 5.) - 5.
test = a
end
! Test copied from reassoc_1.f90 which checked for -fprotect-parens (default),
! and thus for the occurance of "5 - 5".
!
! We need an explicit +5 and -5, and an intermediate ((bla)) expression
! (the reassoc barrier). Make use of "." matching lineends.
! { dg-final { scan-tree-dump-times "\\\+ 5.*\\\)\\\).* - 5" 0 "optimized" } }
! { dg-final { cleanup-tree-dump "optimized" } }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment