This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: How to express the fact that arguments don't escape?
2009/8/16 Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>:
> Richard Guenther wrote:
>>
>> And this effect will only be positive on optimizations if you have like
>>
>> ?do i=1,10
>> ? ? g(i)
>> ? ? ... = function of i
>> ? ? f(k)
>> ? ? ... = function of i
>> ? end do
>>
>> where the load from i can be CSEd around the call to f (because it didn't
>> escape to g). ?So I expect this to be a pretty rare case. ?Note it doesn't
>> help
>> loop optimizations as i is still clobbered in unpredictable ways by g.
>
> It's not allowed to be changed inside the loop, so if i is clobbered inside
> g, the code is undefined.
In that case you can unconditionally omit the copy-back. For the correct
variable of course. Which would then still be profitable (just if you for some
reason require a copy-back it's likely not always profitable).
> But please note that the loop variable (i) and the loop counter (the one
> that appears in the loop condition on the gimple level) are not the same,
> see the comment leading up to gfc_trans_do in trans-stmt.c.
>
> Cheers,
> - Tobi
>