diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2011-10-10 19:07:35 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2011-10-10 19:07:35 +0000 |
commit | 2855325f50569ed1a0c06b1cd8d86fe580472924 (patch) | |
tree | a8e423b877426619210fa4f103847793aae46c08 /gcc/fortran | |
parent | 50da34bb1b301f869253ca55bdb4833baa24ab4e (diff) | |
download | gcc-2855325f50569ed1a0c06b1cd8d86fe580472924.zip gcc-2855325f50569ed1a0c06b1cd8d86fe580472924.tar.gz gcc-2855325f50569ed1a0c06b1cd8d86fe580472924.tar.bz2 |
re PR fortran/50564 (Front-end optimization - ICE with FORALL)
2011-10-10 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/50564
* frontend-passes (forall_level): New variable.
(cfe_register_funcs): Don't register functions if we
are within a forall loop.
(optimize_namespace): Set forall_level to 0 before entry.
(gfc_code_walker): Increase/decrease forall_level.
2011-10-10 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/50564
* gfortran.dg/forall_15.f90: New test case.
From-SVN: r179770
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/fortran/frontend-passes.c | 17 |
2 files changed, 26 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2156e71..64f58e8 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2011-10-10 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/50564 + * frontend-passes (forall_level): New variable. + (cfe_register_funcs): Don't register functions if we + are within a forall loop. + (optimize_namespace): Set forall_level to 0 before entry. + (gfc_code_walker): Increase/decrease forall_level. + 2011-10-09 Tobias Burnus <burnus@net-b.de> PR fortran/45044 diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 16053e0..dcbaf06 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -62,6 +62,10 @@ static gfc_code *inserted_block, **changed_statement; gfc_namespace *current_ns; +/* If we are within any forall loop. */ + +static int forall_level; + /* Entry point - run all passes for a namespace. So far, only an optimization pass is run. */ @@ -165,6 +169,12 @@ cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED, || (*e)->ts.u.cl->length->expr_type != EXPR_CONSTANT)) return 0; + /* We don't do function elimination within FORALL statements, it can + lead to wrong-code in certain circumstances. */ + + if (forall_level > 0) + return 0; + /* If we don't know the shape at compile time, we create an allocatable temporary variable to hold the intermediate result, but only if allocation on assignment is active. */ @@ -493,6 +503,7 @@ optimize_namespace (gfc_namespace *ns) { current_ns = ns; + forall_level = 0; gfc_code_walker (&ns->code, convert_do_while, dummy_expr_callback, NULL); gfc_code_walker (&ns->code, cfe_code, cfe_expr_0, NULL); @@ -1193,6 +1204,8 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t codefn, walk_expr_fn_t exprfn, WALK_SUBEXPR (fa->end); WALK_SUBEXPR (fa->stride); } + if (co->op == EXEC_FORALL) + forall_level ++; break; } @@ -1335,6 +1348,10 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t codefn, walk_expr_fn_t exprfn, WALK_SUBEXPR (b->expr2); WALK_SUBCODE (b->next); } + + if (co->op == EXEC_FORALL) + forall_level --; + } } return 0; |