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

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


On 07/13/2011 12:57 PM, Richard Guenther wrote:
> On Wed, Jul 13, 2011 at 12:30 PM, Tobias Burnus<burnus@net-b.de>  wrote:
>> Example 2: Coarray with sync. The SYNC is not directly called, but via a
>> wrapper function to increase the fun factor.
>>     subroutine sub(coarray)
>>       integer :: coarray[*]
>>       coarray = 5
>>       call SYNC_calling_proc()
>>       ! coarray is modified remotely
>>       call SYNC_calling_proc()
>>       if (coarray /= 5) ...
>>     end subroutine sub
>> Here, the "if" may not be removed as the image could have been changed
>> remotely.
> > From the last two examples it looks like a regular restrict qualified pointer
> would work.  At least I don't see how it would not.

Would it? How does the compiler know that between "call 
SYNC_calling_proc()" the value of "coarray" could change? Hmm, 
seemingly, that's indeed the case, looking at the optimized dump of the 
example above:

sub (integer(kind=4) * restrict coarray)
{
   integer(kind=4) D.1560;
   *coarray_1(D) = 5;
   sync_calling_proc ();
   sync_calling_proc ();
   D.1560_2 = *coarray_1(D);
   if (D.1560_2 != 5)


Well, then I have a different question: How can one tell the middle end 
to optimize the "if (...)" away in the following case? Seemingly having 
an "integer(kind=4) & restrict non_aliasing_var" does not seem to be 
sufficient to do so:

    subroutine sub(non_aliasing_var)
      interface
        subroutine some_function()
        end subroutine some_function
      end interface

      integer :: non_aliasing_var
      non_aliasing_var = 5
      call some_function()
      if (non_aliasing_var /= 5) call foobar_()
    end subroutine sub

That's an optimization, which other compiles do - such as NAG or 
PathScale/Open64/sunf95.

Tobias



More information about the Gcc mailing list