public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/38114]  New: unneeded temp
@ 2008-11-14  8:59 jv244 at cam dot ac dot uk
  2008-11-18 20:10 ` [Bug fortran/38114] " pault at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jv244 at cam dot ac dot uk @ 2008-11-14  8:59 UTC (permalink / raw)
  To: gcc-bugs

no need for a temp here. 

SUBROUTINE S(b,i,j)
INTEGER, DIMENSION(:) :: b
INTEGER :: i,j
write(6,*) MINLOC(b(i:j))
END SUBROUTINE S


-- 
           Summary: unneeded temp
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jv244 at cam dot ac dot uk
OtherBugsDependingO 36854
             nThis:


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/38114] unneeded temp
  2008-11-14  8:59 [Bug fortran/38114] New: unneeded temp jv244 at cam dot ac dot uk
@ 2008-11-18 20:10 ` pault at gcc dot gnu dot org
  2008-11-19 13:09 ` jv244 at cam dot ac dot uk
  2009-03-29  8:27 ` fxcoudert at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-18 20:10 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/38114] unneeded temp
  2008-11-14  8:59 [Bug fortran/38114] New: unneeded temp jv244 at cam dot ac dot uk
  2008-11-18 20:10 ` [Bug fortran/38114] " pault at gcc dot gnu dot org
@ 2008-11-19 13:09 ` jv244 at cam dot ac dot uk
  2009-03-29  8:27 ` fxcoudert at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: jv244 at cam dot ac dot uk @ 2008-11-19 13:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jv244 at cam dot ac dot uk  2008-11-19 13:08 -------
(In reply to comment #1)
> SUBROUTINE S(b,i,j)
> INTEGER, DIMENSION(:) :: b
> integer res(1)
> INTEGER :: i,j
> res = MINLOC(b(i:j))
> END SUBROUTINE S

right.. the 'orginal' testcase was. Actually, these temps are all derived for
CP2K sources.

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


-- 


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/38114] unneeded temp
  2008-11-14  8:59 [Bug fortran/38114] New: unneeded temp jv244 at cam dot ac dot uk
  2008-11-18 20:10 ` [Bug fortran/38114] " pault at gcc dot gnu dot org
  2008-11-19 13:09 ` jv244 at cam dot ac dot uk
@ 2009-03-29  8:27 ` fxcoudert at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2009-03-29  8:27 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-03-29 08:27:46
               date|                            |


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-03-29  8:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-14  8:59 [Bug fortran/38114] New: unneeded temp jv244 at cam dot ac dot uk
2008-11-18 20:10 ` [Bug fortran/38114] " pault at gcc dot gnu dot org
2008-11-19 13:09 ` jv244 at cam dot ac dot uk
2009-03-29  8:27 ` fxcoudert at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).