[Bug fortran/31014] New: missed-optimization: unnecessary invokation of _gfortran_internal_pack
burnus at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Thu Mar 1 17:55:00 GMT 2007
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
More information about the Gcc-bugs
mailing list