This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/31014] New: missed-optimization: unnecessary invokation of _gfortran_internal_pack
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Mar 2007 17:55:06 -0000
- Subject: [Bug fortran/31014] New: missed-optimization: unnecessary invokation of _gfortran_internal_pack
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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