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> 2010-02-20 David S. Miller <davem@davemloft.net>
* configure.ac: Test if linker and assembler properly support * 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 ...@@ -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. and thus may not be used when ordered comparisons are required.
This option requires that both @option{-fno-signed-zeros} and This option requires that both @option{-fno-signed-zeros} and
@option{-fno-trapping-math} be in effect. Moreover, it doesn't make @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}. 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> 2010-02-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/36932 PR fortran/36932
......
...@@ -2150,6 +2150,7 @@ typedef struct ...@@ -2150,6 +2150,7 @@ typedef struct
char flag_init_character_value; char flag_init_character_value;
int flag_align_commons; int flag_align_commons;
int flag_whole_file; int flag_whole_file;
int flag_protect_parens;
int fpe; int fpe;
int rtcheck; int rtcheck;
......
...@@ -171,7 +171,8 @@ and warnings}. ...@@ -171,7 +171,8 @@ and warnings}.
-fpack-derived -frepack-arrays -fshort-enums -fexternal-blas @gol -fpack-derived -frepack-arrays -fshort-enums -fexternal-blas @gol
-fblas-matmul-limit=@var{n} -frecursive -finit-local-zero @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-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 @end table
@menu @menu
...@@ -1410,6 +1411,16 @@ consistent data types everywhere, this padding can cause trouble, and ...@@ -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. 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 To avoid potential alignment issues in COMMON blocks, it is recommended to order
objects from largests to smallest. 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 @end table
@xref{Code Gen Options,,Options for Code Generation Conventions, @xref{Code Gen Options,,Options for Code Generation Conventions,
......
...@@ -324,6 +324,10 @@ fpreprocessed ...@@ -324,6 +324,10 @@ fpreprocessed
Fortran Fortran
; Documented in C ; Documented in C
fprotect-parens
Fortran
Protect parentheses in expressions
frange-check frange-check
Fortran Fortran
Enable range checking during compilation Enable range checking during compilation
......
...@@ -125,6 +125,7 @@ gfc_init_options (unsigned int argc, const char **argv) ...@@ -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 = GFC_INIT_CHARACTER_OFF;
gfc_option.flag_init_character_value = (char)0; gfc_option.flag_init_character_value = (char)0;
gfc_option.flag_align_commons = 1; gfc_option.flag_align_commons = 1;
gfc_option.flag_protect_parens = 1;
gfc_option.fpe = 0; gfc_option.fpe = 0;
gfc_option.rtcheck = 0; gfc_option.rtcheck = 0;
...@@ -921,6 +922,10 @@ gfc_handle_option (size_t scode, const char *arg, int value) ...@@ -921,6 +922,10 @@ gfc_handle_option (size_t scode, const char *arg, int value)
gfc_option.flag_align_commons = value; gfc_option.flag_align_commons = value;
break; break;
case OPT_fprotect_parens:
gfc_option.flag_protect_parens = value;
break;
case OPT_fcheck_: case OPT_fcheck_:
gfc_handle_runtime_check_option (arg); gfc_handle_runtime_check_option (arg);
break; break;
......
...@@ -1222,8 +1222,9 @@ gfc_conv_expr_op (gfc_se * se, gfc_expr * expr) ...@@ -1222,8 +1222,9 @@ gfc_conv_expr_op (gfc_se * se, gfc_expr * expr)
switch (expr->value.op.op) switch (expr->value.op.op)
{ {
case INTRINSIC_PARENTHESES: case INTRINSIC_PARENTHESES:
if (expr->ts.type == BT_REAL if ((expr->ts.type == BT_REAL
|| expr->ts.type == BT_COMPLEX) || expr->ts.type == BT_COMPLEX)
&& gfc_option.flag_protect_parens)
{ {
gfc_conv_unary_op (PAREN_EXPR, se, expr); gfc_conv_unary_op (PAREN_EXPR, se, expr);
gcc_assert (FLOAT_TYPE_P (TREE_TYPE (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> 2010-02-20 Uros Bizjak <ubizjak@gmail.com>
PR target/43067 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