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
This commit is contained in:
Paul Thomas 2010-07-10 14:57:25 +00:00
parent ccf134c74c
commit 022e30c0b6
4 changed files with 27 additions and 1 deletions

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -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