gfortran seems to generate a spurious _gfortran_internal_pack if an array that is component of a type is passed to a subroutine. More precisely, in the example CALL S1(d%data) CALL S1(data) should basically generate the same pseudocode, but this doesn't happen.
> cat test.f90 MODULE M1 TYPE T1 REAL :: data(10) END TYPE T1 CONTAINS SUBROUTINE S1(data) REAL, DIMENSION(*) :: data END SUBROUTINE S1 END MODULE SUBROUTINE S2 USE M1 TYPE(T1) :: d REAL :: data(10) CALL S1(d%data) CALL S1(data) END SUBROUTINE S2 > cat test.f90.003t.original s1 (real(kind=4)[0:] * data) { (void) 0; } s2 () { struct t1 d; real(kind=4) data[10]; { void * D.1554; struct array1_real(kind=4) parm.0; parm.0.dtype = 281; parm.0.dim[0].lbound = 1; parm.0.dim[0].ubound = 10; parm.0.dim[0].stride = 1; parm.0.data = (void *) &d.data[0]; parm.0.offset = -1; D.1554 = _gfortran_internal_pack (&parm.0); s1 (D.1554); if ((real(kind=4)[0:] *) parm.0.data != (real(kind=4)[0:] *) D.1554) { _gfortran_internal_unpack (&parm.0, D.1554); { void * D.1555; D.1555 = D.1554; if (D.1555 != 0B) { __builtin_free (D.1555); } } } } s1 (&data); } -- Summary: spurious _gfortran_internal_pack Product: gcc Version: 4.5.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 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41113