Hello, Le 09/05/2015 00:11, Thomas Koenig a écrit : > Index: frontend-passes.c > =================================================================== > --- frontend-passes.c (Revision 222864) > +++ frontend-passes.c (Arbeitskopie) > @@ -2611,14 +2611,40 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index, > { > /* Look at full individual sections, like a(:). The > first index > is the lbound of a full ref. */ > - > + int j; > gfc_array_ref *ar; > + gfc_expr *lbound_e; > > - ar = gfc_find_array_ref (e_in); > + lbound_e = gfc_copy_expr (e_in); > + ar = gfc_find_array_ref (lbound_e); > + > ar->type = AR_FULL; > + for (j = 0; j < ar->dimen; j++) > + { > + gfc_free_expr (ar->start[j]); > + ar->start[j] = NULL; > + gfc_free_expr (ar->end[j]); > + ar->end[j] = NULL; > + gfc_free_expr (ar->stride[j]); > + ar->stride[j] = NULL; > + } > + You also need to remove/free the trailing subreferences.
> + /* We have to get rid of the shape, if thre is one. Do > + so by freeing it and calling gfc_resolve to rebuild it, > + if necessary. */ > + > + if (lbound_e->shape) > + gfc_free_shape (&(lbound_e->shape), lbound_e->rank); > + > + lbound_e->rank = ar->dimen; ar->dimen is not what you think it is. It is 3 for array(1, 1, :), while the rank is 1. gfc_resolve_expr should set the rank for you, so just remove this line. > + > + gfc_resolve_expr (lbound_e); > + lbound = get_array_inq_function (GFC_ISYM_LBOUND, > + lbound_e, i + 1); free lbound_e? > } > - lbound = get_array_inq_function (GFC_ISYM_LBOUND, e_in, > - i_index + 1); > + else > + lbound = get_array_inq_function (GFC_ISYM_LBOUND, e_in, > + i_index + 1); You can't reuse e_in if it has subreferences. One suggestion: you may want to move all the above to a function extracting the full array. > } > > ar->dimen_type[i] = DIMEN_ELEMENT; > @@ -2639,6 +2665,8 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index, > i_index ++; > } > } > + gfc_free_expr (e_in); > + This side effect is asking for trouble. Instead of this, remove the copies made in the callers. This is independant from the rest, so it can be made later as a follow-up. > return e; > } > > I attach a variant of your inline_matmul_8.f90 that is not working yet because of subreferences. Mikael
--- inline_matmul_8.f90.old 2015-05-09 13:31:28.420790646 +0200 +++ inline_matmul_8.f90 2015-05-09 13:42:50.741799982 +0200 @@ -3,15 +3,22 @@ ! PR 66041 - this used to ICE with an incomplete fix for the PR. program main implicit none - real, dimension(1,-2:0) :: a1 + type :: t + real :: c + end type t + type(t), dimension(1,-2:0) :: a1 real, dimension(3,2) :: b1 real, dimension(2) :: c1 + real, dimension(1,2) :: c2 - data a1 /17., -23., 29./ + data a1%c /17., -23., 29./ data b1 / 2., -3., 5., -7., 11., -13./ - c1 = matmul(a1(1,:), b1) + c1 = matmul(a1(1,:)%c, b1) if (any (c1-[248., -749.] /= 0.)) call abort + + c2 = matmul(a1%c, b1) + if (any (c2-reshape([248., -749.],shape(c2)) /= 0.)) call abort end program main ! { dg-final { scan-tree-dump-times "_gfortran_matmul" 0 "original" } }