diff options
author | Tobias Burnus <burnus@net-b.de> | 2010-02-21 14:06:07 +0100 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2010-02-21 14:06:07 +0100 |
commit | 72bd130e66f28490198385ff62481a719a0103c0 (patch) | |
tree | d4fbccbf175b1cb47bc63157005e3fbde3964021 | |
parent | c76dc9b0e660bb78b5addda708a1b1eeb53ec1b8 (diff) | |
download | gcc-72bd130e66f28490198385ff62481a719a0103c0.zip gcc-72bd130e66f28490198385ff62481a719a0103c0.tar.gz gcc-72bd130e66f28490198385ff62481a719a0103c0.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 4 | ||||
-rw-r--r-- | gcc/fortran/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/fortran/gfortran.h | 1 | ||||
-rw-r--r-- | gcc/fortran/invoke.texi | 13 | ||||
-rw-r--r-- | gcc/fortran/lang.opt | 4 | ||||
-rw-r--r-- | gcc/fortran/options.c | 5 | ||||
-rw-r--r-- | gcc/fortran/trans-expr.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/reassoc_5.f90 | 19 |
10 files changed, 67 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8975aea..4334c21 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index a7abd01..f661001 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -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}. diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9efaf38..fec057f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -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 diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 71f3fe0..eeaf0af 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -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; diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index 9fe75d1..efcf5ef 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -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, diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index b64dbc7..a52e643 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -324,6 +324,10 @@ fpreprocessed Fortran ; Documented in C +fprotect-parens +Fortran +Protect parentheses in expressions + frange-check Fortran Enable range checking during compilation diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index a9ce560..bcde573 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -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; diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 276e645..d712148 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -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))); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a010e8f..682a7e8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..8d3086a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/reassoc_5.f90 @@ -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" } } |