[Patch, fortran] PR66089 fix elemental dependency mishandling

Mikael Morin mikael.morin@sfr.fr
Mon Feb 1 22:07:00 GMT 2016


Hello,

this is about the case

    c(:) = elemental_func(c(1), ...)

where as a result of a trunk change, only a reference to c(1) is saved 
to a temporary variable, instead of its value.

The fix tries to save the amount of copying as much as possible by 
detecting the above case.  Technically through the usage of a new field 
needs_temporary.

The patch is a variant of the one that has been on bugzilla for months.
The main difference is the usage of gfc_expr_is_variable instead of the 
check for expr_type == EXPR_VARIABLE (the former includes 
pointer-returning functions as well).

Regression-tested on x86_64-unknown-linux-gnu.  OK for trunk?
Mikael

-------------- next part --------------
2016-02-01  Mikael Morin  <mikael@gcc.gnu.org>

	PR fortran/66089
	* trans-expr.c (expr_is_variable, gfc_expr_is_variable): Rename
	the former to the latter and make it non-static.  Update callers.
	* gfortran.h (gfc_expr_is_variable): New declaration.
	(struct gfc_ss_info): Add field needs_temporary.
	* trans-array.c (gfc_scalar_elemental_arg_saved_as_argument):
	Tighten the condition on aggregate expressions with a check
	that the expression is a variable and doesn't need a temporary.
	(gfc_conv_resolve_dependency): Add intermediary reference variable.
	Set the needs_temporary field.

2016-02-01  Mikael Morin  <mikael@gcc.gnu.org>

	PR fortran/66089
	* gfortran.dg/elemental_dependency_6.f90: New.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr66089_v1.diff
Type: text/x-patch
Size: 5192 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20160201/596074ec/attachment.bin>


More information about the Fortran mailing list