diff mbox series

[fortran] Fix PR 56342, matmul was not simplified

Message ID d01e3a28-be31-bc72-0dfb-7cf5d8c89be1@netcologne.de
State New
Headers show
Series [fortran] Fix PR 56342, matmul was not simplified | expand

Commit Message

Thomas Koenig Oct. 22, 2017, 5:39 p.m. UTC
Hello world,

the attached patch fixes the PR by calling gfc_simplify_expr for
parameter arrays, which do not yet appear to simplified completely
by the time they reach gfc_simplify_matmul.

I suspect this will also fix some more simplification issues, but I
didn't search for other cases.

Regression-tested.  OK for trunk?

Regards

	Thomas


2017-10-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/56342
         * simplify.c (is_constant_array_expr): If the expression is
         a parameter array, call gfc_simplify_expr.

2017-10-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/56342
         * gfortran.dg/matmul_const.f90: New test.
diff mbox series

Patch

Index: simplify.c
===================================================================
--- simplify.c	(Revision 253768)
+++ simplify.c	(Arbeitskopie)
@@ -227,7 +227,8 @@ 
 }
 
 
-/* Test that the expression is an constant array.  */
+/* Test that the expression is an constant array, simplifying if
+   we are dealing with a parameter array.  */
 
 static bool
 is_constant_array_expr (gfc_expr *e)
@@ -237,6 +238,10 @@ 
   if (e == NULL)
     return true;
 
+  if (e->expr_type == EXPR_VARIABLE && e->rank > 0
+      && e->symtree->n.sym->attr.flavor == FL_PARAMETER)
+    gfc_simplify_expr (e, 1);
+
   if (e->expr_type != EXPR_ARRAY || !gfc_is_constant_expr (e))
     return false;