diff mbox

[fortran] Fix PR 66111

Message ID 55525D6A.8050106@netcologne.de
State New
Headers show

Commit Message

Thomas Koenig May 12, 2015, 8:07 p.m. UTC
Hello world,

this patch fixes a regression from the inline matmul patch by
not inlining a case that is not yet handled, namely vector
subscripts.

Regression-tested.  OK for trunk?

Regards

	Thomas

2015-05-12  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/66111
        * frontend-passes.c (has_dimen_vector_ref):  New function.
        (inline_matmul_assign):  Use it to return early in case
        of unhandled vector subscripts.

2015-05-12  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/66111
        * gfortran.dg/inline_matmul_10.f90:  New test.

Comments

Mikael Morin May 12, 2015, 8:35 p.m. UTC | #1
Hello,

Le 12/05/2015 22:07, Thomas Koenig a écrit :
> Hello world,
> 
> this patch fixes a regression from the inline matmul patch by
> not inlining a case that is not yet handled, namely vector
> subscripts.
> 
> Regression-tested.  OK for trunk?
> 
OK with...
> 
> Index: frontend-passes.c
> ===================================================================
> --- frontend-passes.c	(Revision 222984)
> +++ frontend-passes.c	(Arbeitskopie)
> @@ -2752,6 +2771,10 @@ inline_matmul_assign (gfc_code **c, int *walk_subt
>        || matrix_b->expr_type != EXPR_VARIABLE)
>      return 0;
>  
> +  if (has_dimen_vector_ref (expr1) ||
> +      has_dimen_vector_ref (matrix_a) || has_dimen_vector_ref (matrix_b))
> +    return 0;
> +

...the operator || at the beginning of the line.

Thanks.

Mikael
diff mbox

Patch

Index: frontend-passes.c
===================================================================
--- frontend-passes.c	(Revision 222984)
+++ frontend-passes.c	(Arbeitskopie)
@@ -2680,7 +2680,26 @@  scalarized_expr (gfc_expr *e_in, gfc_expr **index,
   return e;
 }
 
+/* Helper function to check for a dimen vector as subscript.  */
 
+static bool
+has_dimen_vector_ref (gfc_expr *e)
+{
+  gfc_array_ref *ar;
+  int i;
+
+  ar = gfc_find_array_ref (e);
+  gcc_assert (ar);
+  if (ar->type == AR_FULL)
+    return false;
+
+  for (i=0; i<ar->dimen; i++)
+    if (ar->dimen_type[i] == DIMEN_VECTOR)
+      return true;
+
+  return false;
+}
+
 /* Inline assignments of the form c = matmul(a,b).
    Handle only the cases currently where b and c are rank-two arrays.
 
@@ -2752,6 +2771,10 @@  inline_matmul_assign (gfc_code **c, int *walk_subt
       || matrix_b->expr_type != EXPR_VARIABLE)
     return 0;
 
+  if (has_dimen_vector_ref (expr1) ||
+      has_dimen_vector_ref (matrix_a) || has_dimen_vector_ref (matrix_b))
+    return 0;
+
   if (matrix_a->rank == 2)
     m_case = matrix_b->rank == 1 ? A2B1 : A2B2;
   else