public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31014]  New: missed-optimization: unnecessary invokation of _gfortran_internal_pack
@ 2007-03-01 17:55 burnus at gcc dot gnu dot org
  2007-03-01 19:22 ` [Bug fortran/31014] " burnus at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-01 17:55 UTC (permalink / raw)
  To: gcc-bugs

Calling _gfortran_internal_pack is not needed, if it is clear that the array is
contiguous. If it is further known that the called procedure uses 
dimension(*), the creation of the array struct is also unnessarily.

In the following, the  _gfortran_internal_pack call itself is unneeded:

  external foo

  ! At compile-time known bounds, could be a local or dummy variable
  ! Could also be the dummy argument "a(*)",
  ! if one specifies below the bounds "a(1:<some value>[:1])"
  real :: a(2:12)

  call foo( a(:) ) 
  call foo( a(2:) )
  call foo( a(:12) )
  call foo( a(2:12:1) )

The current tree looks like:
    struct array1_real4 parm.0;
    parm.0.dtype = 281;
    [...] // Initialize array struct, OK!

    D.1362 = _gfortran_internal_pack (&parm.0);
    foo (D.1362);
        _gfortran_internal_unpack (&parm.0, D.1362);
        _gfortran_internal_free (D.1362);

The last four lines can be replaced by a simple "foo(&parm.0)".


Note that for one dimension, even
  call foo (a(2:5) ) ! reduced ubound
or
  call foo ( a(4:)) ! increased lbound
are possible without needing _gfortran_internal_pack.


If one knows that the called subroutine takes dimension(*) then there is also
no need to fill the array struct:

 interface
   subroutine foo(x)
     real :: x(*)
   end subroutine foo
 end interface
 real :: a(*) ! Can also be, e.g. "a(1:12)"

 call foo(a(2:5:1))
end subroutine

Here, one can simply call

   foo(&a[1])

instead of filling the array struct and calling then _gfortran_internal_pack.


-- 
           Summary: missed-optimization: unnecessary invokation of
                    _gfortran_internal_pack
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

* [Bug fortran/31014] missed-optimization: unnecessary invokation of _gfortran_internal_pack
  2007-03-01 17:55 [Bug fortran/31014] New: missed-optimization: unnecessary invokation of _gfortran_internal_pack burnus at gcc dot gnu dot org
@ 2007-03-01 19:22 ` burnus at gcc dot gnu dot org
  2007-03-01 19:36 ` tkoenig at gcc dot gnu dot org
  2010-02-20 22:17 ` burnus at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-01 19:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2007-03-01 19:22 -------
And analogously for these kinds of dummy arguments:

subroutine x(a,n)
 integer :: n
 real :: a(n)
 interface
   subroutine foo(x,n)
     integer :: n
     real :: x(n)
   end subroutine foo
 end interface

 call foo(a(:),n)
end


-- 


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


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

* [Bug fortran/31014] missed-optimization: unnecessary invokation of _gfortran_internal_pack
  2007-03-01 17:55 [Bug fortran/31014] New: missed-optimization: unnecessary invokation of _gfortran_internal_pack burnus at gcc dot gnu dot org
  2007-03-01 19:22 ` [Bug fortran/31014] " burnus at gcc dot gnu dot org
@ 2007-03-01 19:36 ` tkoenig at gcc dot gnu dot org
  2010-02-20 22:17 ` burnus at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-03-01 19:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from tkoenig at gcc dot gnu dot org  2007-03-01 19:36 -------
Confirmed.


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-03-01 19:36:13
               date|                            |


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


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

* [Bug fortran/31014] missed-optimization: unnecessary invokation of _gfortran_internal_pack
  2007-03-01 17:55 [Bug fortran/31014] New: missed-optimization: unnecessary invokation of _gfortran_internal_pack burnus at gcc dot gnu dot org
  2007-03-01 19:22 ` [Bug fortran/31014] " burnus at gcc dot gnu dot org
  2007-03-01 19:36 ` tkoenig at gcc dot gnu dot org
@ 2010-02-20 22:17 ` burnus at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-20 22:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2010-02-20 22:17 -------
Close as FIXED. Seemingly, the issues reported here are now fixed. Cf.
http://gcc.gnu.org/ml/fortran/2010-02/msg00162.html and PR 36932, PR 36933, PR
43072, and PR 43111.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2010-02-20 22:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-01 17:55 [Bug fortran/31014] New: missed-optimization: unnecessary invokation of _gfortran_internal_pack burnus at gcc dot gnu dot org
2007-03-01 19:22 ` [Bug fortran/31014] " burnus at gcc dot gnu dot org
2007-03-01 19:36 ` tkoenig at gcc dot gnu dot org
2010-02-20 22:17 ` burnus 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).