http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55980
Bug #: 55980 Summary: missed optimizations with internal_pack Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: ja...@gcc.gnu.org This is a tracking bug for possible remaining problems of PR 55072: ------------------------------------------------------------------- 1) In PR 55072 comment 13, Mikael writes about this patchlet: > Index: gcc/fortran/trans-array.c > =================================================================== > --- gcc/fortran/trans-array.c (revision 194517) > +++ gcc/fortran/trans-array.c (working copy) > @@ -6995,20 +6995,14 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * > this_array_result = false; > > /* Passing address of the array if it is not pointer or assumed-shape. */ > - if (full_array_var && g77 && !this_array_result) > + if (full_array_var && g77 && !this_array_result > + && sym->ts.type != BT_DERIVED && sym->ts.type != BT_CLASS) > { > tmp = gfc_get_symbol_decl (sym); It feels like a hack (that what there before) to blindly disable derived types here. The real problem is that the code under the if condition supports only bare variables without subreferences. On the other hand it looks like a correct hack WRT the existing behaviour. ------------------------------------------------------------------- 2) In http://gcc.gnu.org/ml/fortran/2012-12/msg00098.html, Tobias writes: "Without experimenting more carefully, I have the gut feeling that there are still cases where we might end up with invalid code and there is missed optimization." [For more details see his full post.] ------------------------------------------------------------------- 3) In http://gcc.gnu.org/ml/fortran/2013-01/msg00091.html, Mikael writes: For: >>> @@ -6995,20 +6995,14 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * >>> this_array_result = false; >>> /* Passing address of the array if it is not pointer or >>> assumed-shape. */ >>> - if (full_array_var&& g77&& !this_array_result) >>> + if (full_array_var&& g77&& !this_array_result >>> +&& sym->ts.type != BT_DERIVED&& sym->ts.type != BT_CLASS) I would have used instead: && expr->expr_type == EXPR_VARIABLE && ref == NULL) to make the optimization available to variables of derived type.