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

            Bug ID: 81773
           Summary: [Coarray] Get with vector index on lhs leads to
                    incorrect caf_get_by_ref() call.
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vehre at gcc dot gnu.org
  Target Milestone: ---

Created attachment 41951
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41951&action=edit
Dump

Fortran code like:

tv(loc_idx(1:nhl,ip)) = xv%v(rmt_idx(1:nhl,ip))[xchg(ip)]

leads to the generation of pseudo-code:

              atmp.33.dtype = 281;
              atmp.33.dim[0].stride = 1;
              atmp.33.dim[0].lbound = 0;
              atmp.33.dim[0].ubound = 1;
              atmp.33.data = (void * restrict) &A.34;
              atmp.33.offset = 0;
              {
                integer(kind=8) S.35;

                S.35 = 0;
                while (1)
                  {
                    if (S.35 > 1) goto L.26;
                    {
                      integer(kind=4) D.3704;

                      D.3704 = (*(integer(kind=4)[0:] *)
parm.32.data)[parm.32.dim[0].stride * NON_LVALUE_EXPR <S.35>];
                      (*(real(kind=4)[2] * restrict) atmp.33.data)[S.35] =
(*D.3696)[(integer(kind=8)) D.3704 + D.3697];
                    }
                    S.35 = S.35 + 1;
                  }
                L.26:;
              }
              atmp.33.dtype = 281;
              caf_ref.36.type = 1;
<snip>
              __asm__ __volatile__("":::"memory");
              _gfortran_caf_get_by_ref (xv.v.token, ((*(integer(kind=4)[0:] *
restrict) xchg.data)[xchg.offset + (integer(kind=8)) ip] - (integer(kind=4))
xv.v.dim[1].lbound) + 1, &atmp.33, &caf_ref.36, 4, 4, 0, 0, 0B);

without copying back the result afterwards. In fact is the while(1) loop above
unnecessary, because atmp.33 is write-only in this call.

Example and dump attached.

Reply via email to