[Patch, fortran] PR4773 - [4.6 Regression] Unnecessary temporaries increase the runtime for channel.f90 by ~70%
Paul Richard Thomas
paul.richard.thomas@gmail.com
Fri Jul 9 15:04:00 GMT 2010
Revision 161670 affected an optimization used for
array_lhs = array_valued_function (args...).
In order to prevent aliasing with the result, which is passed by
reference, a fairly conservative test was applied to generate a
temporary, if needed. Unfortunately, this reduced the performance of
gfortran with some code; most notably with channel.f90.
This patch tests if the 'array_lhs' has ever been host associated, on
condition that 'array_valued_function' is contained, in addition to
checking that the result is not use-associated, a pointer or a target.
If this is not the case, no temporary is generated.
Clearly some further optimization would be possible, if the
'array_lhs' were specifically not host associated to
'array_valued_function' OR ANY OF IT'S CALLEEs. This latter
condition is rather difficult to implement, which is why I have not
even tried it.
Bootstrapped and regtested on RHEL5.3/i686 - OK for trunk and.....?
Cheers
Paul
2010-07-09 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: submit.diff
Type: text/x-patch
Size: 2041 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100709/bcee7552/attachment.bin>
More information about the Gcc-patches
mailing list