diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2010-07-10 14:57:25 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2010-07-10 14:57:25 +0000 |
commit | 022e30c0b67a70587b22fc67f7a7e11e0600005f (patch) | |
tree | 80d52358390417552d8db01d6fc4df580bda732c | |
parent | ccf134c74c7d1bc0511fdc648c9996164c44437d (diff) | |
download | gcc-022e30c0b67a70587b22fc67f7a7e11e0600005f.zip gcc-022e30c0b67a70587b22fc67f7a7e11e0600005f.tar.gz gcc-022e30c0b67a70587b22fc67f7a7e11e0600005f.tar.bz2 |
re PR fortran/44773 (Unnecessary temporaries increase the runtime for channel.f90 by ~70%)
2010-07-10 Paul Thomas <pault@gcc.gnu.org>
PR fortran/44773
* trans-expr.c (arrayfunc_assign_needs_temporary): No temporary
if the lhs has never been host associated, as well as not being
use associated, a pointer or a target.
* resolve.c (resolve_variable): Mark variables that are host
associated.
* gfortran.h: Add the host_assoc bit to the symbol_attribute
structure.
From-SVN: r162038
-rw-r--r-- | gcc/fortran/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/fortran/gfortran.h | 3 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 9 | ||||
-rw-r--r-- | gcc/fortran/trans-expr.c | 5 |
4 files changed, 27 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f43a33b..e4837b4 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,14 @@ +2010-07-10 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/44773 + * trans-expr.c (arrayfunc_assign_needs_temporary): No temporary + if the lhs has never been host associated, as well as not being + use associated, a pointer or a target. + * resolve.c (resolve_variable): Mark variables that are host + associated. + * gfortran.h: Add the host_assoc bit to the symbol_attribute + structure. + 2010-07-09 Janus Weil <janus@gcc.gnu.org> * intrinsic.texi: Add documentation for SAME_TYPE_AS, EXTENDS_TYPE_OF, diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 3797926..6086480 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -682,7 +682,8 @@ typedef struct use_assoc:1, /* Symbol has been use-associated. */ use_only:1, /* Symbol has been use-associated, with ONLY. */ use_rename:1, /* Symbol has been use-associated and renamed. */ - imported:1; /* Symbol has been associated by IMPORT. */ + imported:1, /* Symbol has been associated by IMPORT. */ + host_assoc:1; /* Symbol has been host associated. */ unsigned in_namelist:1, in_common:1, in_equivalence:1; unsigned function:1, subroutine:1, procedure:1; diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index a8ed544..98d1e07 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -4772,6 +4772,15 @@ resolve_variable (gfc_expr *e) sym->entry_id = current_entry_id + 1; } + /* If a symbol has been host_associated mark it. This is used latter, + to identify if aliasing is possible via host association. */ + if (sym->attr.flavor == FL_VARIABLE + && gfc_current_ns->parent + && (gfc_current_ns->parent == sym->ns + || (gfc_current_ns->parent->parent + && gfc_current_ns->parent->parent == sym->ns))) + sym->attr.host_assoc = 1; + resolve_procedure: if (t == SUCCESS && resolve_procedure_expression (e) == FAILURE) t = FAILURE; diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index ea8b892..5f2eda2 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -4978,6 +4978,11 @@ arrayfunc_assign_needs_temporary (gfc_expr * expr1, gfc_expr * expr2) if (!expr2->value.function.esym->attr.contained) return false; + /* A temporary is not needed if the lhs has never been host + associated and the procedure is contained. */ + else if (!sym->attr.host_assoc) + return false; + /* A temporary is not needed if the variable is local and not a pointer, a target or a result. */ if (sym->ns->parent |