------- Comment #1 from pault at gcc dot gnu dot org  2008-11-18 20:09 -------
This produces the code:

s (struct array1_integer(kind=4) & b, integer(kind=4) & i, integer(kind=4) & j)
{
  integer(kind=8) ubound.0;
  integer(kind=8) stride.1;
  integer(kind=8) offset.2;
  integer(kind=8) size.3;
  integer(kind=4)[0:D.1562] * b.0;
  integer(kind=8) D.1562;
  bit_size_type D.1563;
  <unnamed-unsigned:64> D.1564;

  {
    integer(kind=8) D.1561;

    D.1561 = b->dim[0].stride;
    stride.1 = D.1561 != 0 ? D.1561 : 1;
    b.0 = (integer(kind=4)[0:D.1562] *) b->data;
    ubound.0 = (b->dim[0].ubound - b->dim[0].lbound) + 1;
    size.3 = stride.1 * NON_LVALUE_EXPR <ubound.0>;
    offset.2 = -stride.1;
    D.1562 = size.3 + -1;
    D.1563 = (bit_size_type) size.3 * 32;
    D.1564 = (<unnamed-unsigned:64>) size.3 * 4;
  }
  {
    struct __st_parameter_dt dt_parm.4;

    dt_parm.4.common.filename = &"pr38114.f90"[1]{lb: 1 sz: 1};
    dt_parm.4.common.line = 4;
    dt_parm.4.common.flags = 128;
    dt_parm.4.common.unit = 6;
    _gfortran_st_write (&dt_parm.4);
    {
      integer(kind=4) A.7[1];
      struct array1_integer(kind=4) atmp.6;
      integer(kind=8) D.1554;
      integer(kind=8) D.1553;
      struct array1_integer(kind=4) parm.5;
      integer(kind=8) D.1551;
      integer(kind=8) D.1550;

      D.1550 = (integer(kind=8)) *i;
      D.1551 = (integer(kind=8)) *j;
      parm.5.dtype = 265;
      D.1553 = offset.2;
      D.1554 = stride.1;
      parm.5.dim[0].lbound = 1;
      parm.5.dim[0].ubound = (1 - D.1550) + D.1551;
      parm.5.dim[0].stride = NON_LVALUE_EXPR <D.1554>;
      parm.5.data = (void *) &(*b.0)[(D.1550 + -1) * D.1554];
      parm.5.offset = (1 - D.1550) * stride.1 + D.1553;
      atmp.6.dtype = 265;
      atmp.6.dim[0].stride = 1;
      atmp.6.dim[0].lbound = 0;
      atmp.6.dim[0].ubound = 0;
      atmp.6.data = (void *) &A.7;
      atmp.6.offset = 0;
      _gfortran_minloc0_4_i4 (&atmp.6, &parm.5);
      {
        integer(kind=8) S.8;

        S.8 = 0;
        while (1)
          {
            if (S.8 > 0) goto L.1;
            {
              integer(kind=4) D.1559;

              D.1559 = (*(integer(kind=4)[1] *) atmp.6.data)[S.8];
              _gfortran_transfer_integer (&dt_parm.4, &D.1559, 4);
            }
            S.8 = S.8 + 1;
          }
        L.1:;
      }
    }
    _gfortran_st_write_done (&dt_parm.4);
  }
}

This does indeed produce a temporary for the result.  The argument is a
descriptor with 'b' as the 'data'.  The result, being rank 1, is a stack array
of size = 1.  I think that this is not a missed optimisation.

For
SUBROUTINE S(b,i,j)
INTEGER, DIMENSION(:) :: b
integer res(1)
INTEGER :: i,j
res = MINLOC(b(i:j))
END SUBROUTINE S

No temporary is produced.

Paul


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38114

Reply via email to