RFH: Impose code-movement restrictions and value assumption (for ASYNCHRONOUS/Coarrays)

Tobias Burnus burnus@net-b.de
Wed Jul 13 13:58:00 GMT 2011


On 07/13/2011 03:46 PM, Tobias Burnus wrote:
> On 07/13/2011 03:27 PM, Ian Lance Taylor wrote:
[...]
>> it doesn't say anything about functions, and in general a call to a
>> function can change any memory pointed to by any pointer.

I misread the paragraph - in particular the last sentence. In Fortran 
that's not the case. Fortran alias rules says that a dummy argument may 
only be modified through the dummy argument, i.e. for

    subroutine foo(a, b)  ! "a" and "b" are passed by reference
      integer :: a, b
      a = 5
      b = 6
      call bar()

the value of "a" is neither modified by "b = 6" nor by "call bar()". 
Exception: If "a" is a target (i.e. some pointer may point to it) or "a" 
is a POINTER.

Thus, in my test case, the function call does not may change the value - 
and, thus, the "if" block can be optimized away.

See quote of the Fortran standard at
   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49733#c0

Seemingly, in C only the first case, Fortran's "b = 5" (C: "*b = 5"), 
would be guaranteed to be not affected if "a" (and "b") are "restrict", 
while the function call can change the value.


In that sense, I do not seem to need a new flags for 
asynchronous/coarrays - which are handled by TYPE_QUAL_RESTRICT, but I 
need a new flag for normal (noncoarray, nonasychronous) variables, which 
are passed by value or are allocatable - and where a function call won't 
affect the value.

Tobias



More information about the Fortran mailing list