From 7fc67fcb4d25203b8bbdeb5a4b914879a7cbf3f9 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sun, 10 May 2015 18:08:33 +0000 Subject: re PR fortran/66041 (Matmul ICE) 2015-05-10 Thomas Koenig PR fortran/66041 * frontend-passes.c (scalarized_expr): Set correct dimension and shape for the expression to be passed to lbound. Remove trailing references after array refrence. (inline_matmul_assign): Remove gfc_copy_expr from calls to scalarized_expr(). 2015-05-10 Thomas Koenig PR fortran/66041 * gfortran.dg/inline_matmul_7.f90: New test. * gfortran.dg/inline_matmul_8.f90: New test. * gfortran.dg/inline_matmul_9.f90: New test. From-SVN: r222982 --- gcc/fortran/ChangeLog | 11 +++++++- gcc/fortran/frontend-passes.c | 64 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 61 insertions(+), 14 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b91f503..4b1c84f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,9 +1,18 @@ +2015-05-10 Thomas Koenig + + PR fortran/66041 + * frontend-passes.c (scalarized_expr): Set correct dimension and + shape for the expression to be passed to lbound. Remove trailing + references after array refrence. + (inline_matmul_assign): Remove gfc_copy_expr from calls + to scalarized_expr(). + 2015-05-10 Mikael Morin * simplify.c (simplify_bound_dim): Don't check for emptyness in the case of cobound simplification. Factor lower/upper bound differenciation before the actual simplification. - (simplify_bound): Remove assumed shape specific simplification. + (simplify_bound): Remove assumed shape specific simplification. Don't give up early for the lbound of an assumed shape. 2015-05-09 Mikael Morin diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 62d1063..30085e8 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -2607,18 +2607,55 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index, int count_index) } else { + gfc_expr *lbound_e; + gfc_ref *ref; + + lbound_e = gfc_copy_expr (e_in); + + for (ref = lbound_e->ref; ref; ref = ref->next) + if (ref->type == REF_ARRAY + && (ref->u.ar.type == AR_FULL + || ref->u.ar.type == AR_SECTION)) + break; + + if (ref->next) + { + gfc_free_ref_list (ref->next); + ref->next = NULL; + } + if (!was_fullref) { /* Look at full individual sections, like a(:). The first index is the lbound of a full ref. */ - + int j; gfc_array_ref *ar; - ar = gfc_find_array_ref (e_in); + ar = &ref->u.ar; 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; + } + + /* We have to get rid of the shape, if there 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; + gfc_resolve_expr (lbound_e); } - lbound = get_array_inq_function (GFC_ISYM_LBOUND, e_in, - i_index + 1); + lbound = get_array_inq_function (GFC_ISYM_LBOUND, lbound_e, + i + 1); + gfc_free_expr (lbound_e); } ar->dimen_type[i] = DIMEN_ELEMENT; @@ -2639,6 +2676,7 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index, int count_index) i_index ++; } } + return e; } @@ -2929,15 +2967,15 @@ inline_matmul_assign (gfc_code **c, int *walk_subtrees, list[0] = var_3; list[1] = var_1; - cscalar = scalarized_expr (gfc_copy_expr (co->expr1), list, 2); + cscalar = scalarized_expr (co->expr1, list, 2); list[0] = var_3; list[1] = var_2; - ascalar = scalarized_expr (gfc_copy_expr (matrix_a), list, 2); + ascalar = scalarized_expr (matrix_a, list, 2); list[0] = var_2; list[1] = var_1; - bscalar = scalarized_expr (gfc_copy_expr (matrix_b), list, 2); + bscalar = scalarized_expr (matrix_b, list, 2); break; @@ -2955,14 +2993,14 @@ inline_matmul_assign (gfc_code **c, int *walk_subtrees, var_2 = do_2->ext.iterator->var; list[0] = var_2; - cscalar = scalarized_expr (gfc_copy_expr (co->expr1), list, 1); + cscalar = scalarized_expr (co->expr1, list, 1); list[0] = var_2; list[1] = var_1; - ascalar = scalarized_expr (gfc_copy_expr (matrix_a), list, 2); + ascalar = scalarized_expr (matrix_a, list, 2); list[0] = var_1; - bscalar = scalarized_expr (gfc_copy_expr (matrix_b), list, 1); + bscalar = scalarized_expr (matrix_b, list, 1); break; @@ -2980,14 +3018,14 @@ inline_matmul_assign (gfc_code **c, int *walk_subtrees, var_2 = do_2->ext.iterator->var; list[0] = var_1; - cscalar = scalarized_expr (gfc_copy_expr (co->expr1), list, 1); + cscalar = scalarized_expr (co->expr1, list, 1); list[0] = var_2; - ascalar = scalarized_expr (gfc_copy_expr (matrix_a), list, 1); + ascalar = scalarized_expr (matrix_a, list, 1); list[0] = var_2; list[1] = var_1; - bscalar = scalarized_expr (gfc_copy_expr (matrix_b), list, 2); + bscalar = scalarized_expr (matrix_b, list, 2); break; -- cgit v1.1