https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81069

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
> The immediate reason for the failure is a bug in the ptx JIT compiler.

The minimal openacc program triggering this is:
...
program foo
  integer :: a(2,2,4), k, kk, kkk
  a = 2

  !$acc parallel num_gangs(1) num_workers(1) vector_length(32)                  

  !$acc loop gang(static:1)                                                     
  do k=1,2
     if (any(a(k,1:2,1:4).ne.2)) call abort
  enddo

  !$acc loop gang(static:1)                                                     
  do k=1,2
     if (any(a(k,1:2,1:4).ne.2)) call abort
  enddo
  !$acc end parallel                                                            

end program
...

With -mno-optimize we have:
...
        @!%r52  bra.uni $L4;                                                    

        bra     $L3;                                                            

        ...

$L3:
        @%r65   bra     $L18;                                                   
                mov.u32 %r23, %r64;                                             
                setp.ne.u32     %r59, %r30, 1;                                  
$L18:
 ...

and with -moptimize we have:
...
        @!%r52  bra.uni $L4;                                                    

        @%r65   bra     $L20;                                                   
                bra     $L3;                                                    

        ...

$L3:
                mov.u32 %r23, %r64;                                             
                setp.ne.u32     %r59, %r30, 1;                                 
                                   $L20:
...

So, -moptimize has extended the sese region being neutered, by including the
branch to $L3. 

In general the point of -moptimize is to combine individual blocks that need to
be neutered:
...
      if !V0 goto L1;
      A
L1:
      if !V0 goto L2;
      B
L2:
...
into neutering of a sese region containing the blocks:
...
      if !V0 goto L2;
      A
      B
L2:
...

But in this case, we're extending the sese region being neutered to include a
branch that doesn't have to be neutered. I don't think there's a purpose in
doing that.

Reply via email to