]> gcc.gnu.org Git - gcc.git/commitdiff
re PR fortran/35259 (-fassociative-math not enabled by default; No option to associa...
authorTobias Burnus <burnus@net-b.de>
Sun, 21 Feb 2010 13:06:07 +0000 (14:06 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Sun, 21 Feb 2010 13:06:07 +0000 (14:06 +0100)
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

gcc/ChangeLog
gcc/doc/invoke.texi
gcc/fortran/ChangeLog
gcc/fortran/gfortran.h
gcc/fortran/invoke.texi
gcc/fortran/lang.opt
gcc/fortran/options.c
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/reassoc_5.f90 [new file with mode: 0644]

index 8975aea4f16863af5fb453b6f5ed77863f75f829..4334c21380bf021ee3720d24b20f92c5fbe1569a 100644 (file)
@@ -1,3 +1,9 @@
+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
index a7abd01c940cacfd4439b3898c1768ced9604459..f6610019802c8b7844c3694129725f6b1598e3fa 100644 (file)
@@ -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}.
 
index 9efaf383ba2ec8e7434b2e3a823728984582f144..fec057ff4e310edb3439765190253cc08ddeecad 100644 (file)
@@ -1,3 +1,12 @@
+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
index 71f3fe054ab7f72233cd67a2ad59e0748abe1d25..eeaf0af8b7f8f0718bd71b2fd794b5a75921d4a1 100644 (file)
@@ -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;
index 9fe75d17b8b716537de83c86e6006d245ffe5f0e..efcf5ef9b45c0449b2b1a08a82f6e5c25c21b988 100644 (file)
@@ -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,
index b64dbc7f3861c8d979073b4cccdb657fda5c50fc..a52e643c9b36727b1d56b4bedc7daaacff394b64 100644 (file)
@@ -324,6 +324,10 @@ fpreprocessed
 Fortran
 ; Documented in C
 
+fprotect-parens
+Fortran
+Protect parentheses in expressions
+
 frange-check
 Fortran
 Enable range checking during compilation
index a9ce56015ae15cde2c6b77fe6d88b68bc99ecddf..bcde573726172f1a1a44a636c11360fb0a126e22 100644 (file)
@@ -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;
index 276e6456c2bbd9b979888aec5450eafa2649dbe5..d71214884e2a1a42b178f1de95f3042006cacda7 100644 (file)
@@ -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)));
index a010e8f4ea8a0cd1378fcb71f80b9bcd0111e705..682a7e8d6f520ffb675694e4423cb75724dbdde0 100644 (file)
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/gfortran.dg/reassoc_5.f90 b/gcc/testsuite/gfortran.dg/reassoc_5.f90
new file mode 100644 (file)
index 0000000..8d3086a
--- /dev/null
@@ -0,0 +1,19 @@
+! { 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" } }
This page took 0.102599 seconds and 5 git commands to generate.