Patchwork [fortran] Front-end optimizations for contained namespaces

login
register
mail settings
Submitter Thomas Koenig
Date Sept. 3, 2010, 8:54 p.m.
Message ID <1283547279.4759.3.camel@linux-fd1f.site>
Download mbox | patch
Permalink /patch/63725/
State New
Headers show

Comments

Thomas Koenig - Sept. 3, 2010, 8:54 p.m.
Hello world,

this patch makes sure that front-end optimizations are also applied to
contained procedures.

Regression-tested.  OK for trunk?

	Thomas

2010-09-03  Thomas Koenig  <tkoenig@gcc.gnu.org>

	* dump_parse_tree (gfc_run_passes):  Call optimize_namespace
	instead of optimize_code.
	(optimize_namespace):  New function.
	
2010-09-03  Thomas Koenig  <tkoenig@gcc.gnu.org>

	* gfortran.dg/trim_optimize_2.f90:  New test.
Tobias Burnus - Sept. 3, 2010, 9:03 p.m.
Thomas Koenig wrote:
> this patch makes sure that front-end optimizations are also applied to
> contained procedures.
>
> Regression-tested.  OK for trunk?

OK - well spotted!

Tobias

> 2010-09-03  Thomas Koenig<tkoenig@gcc.gnu.org>
>
> 	* dump_parse_tree (gfc_run_passes):  Call optimize_namespace
> 	instead of optimize_code.
> 	(optimize_namespace):  New function.
> 	
> 2010-09-03  Thomas Koenig<tkoenig@gcc.gnu.org>
>
> 	* gfortran.dg/trim_optimize_2.f90:  New test.
>
Mikael Morin - Sept. 3, 2010, 9:03 p.m.
Le 03.09.2010 22:54, Thomas Koenig a écrit :
> Hello world,
>
> this patch makes sure that front-end optimizations are also applied to
> contained procedures.
>
> Regression-tested.  OK for trunk?
OK. Thanks.
Thomas Koenig - Sept. 3, 2010, 9:22 p.m.
Hello Tobias,

> Thomas Koenig wrote:
> > this patch makes sure that front-end optimizations are also applied to
> > contained procedures.
> >
> > Regression-tested.  OK for trunk?
> 
> OK - well spotted!

Committed as rev. 163846.  Thanks to you and Mikael for the ultra-fast
reviews!

	Thomas

Patch

Index: frontend-passes.c
===================================================================
--- frontend-passes.c	(Revision 163835)
+++ frontend-passes.c	(Arbeitskopie)
@@ -28,6 +28,7 @@ 
 /* Forward declarations.  */
 
 static void strip_function_call (gfc_expr *);
+static void optimize_namespace (gfc_namespace *);
 static void optimize_assignment (gfc_code *);
 static void optimize_expr_0 (gfc_expr *);
 static bool optimize_expr (gfc_expr *);
@@ -41,13 +42,24 @@ 
    optimization pass is run.  */
 
 void
-gfc_run_passes (gfc_namespace * ns)
+gfc_run_passes (gfc_namespace *ns)
 {
   if (optimize)
-    optimize_code (ns->code);
+    optimize_namespace (ns);
 }
 
+/* Optimize a namespace, including all contained namespaces.  */
+
 static void
+optimize_namespace (gfc_namespace *ns)
+{
+  optimize_code (ns->code);
+
+  for (ns = ns->contained; ns; ns = ns->sibling)
+    optimize_namespace (ns);
+}
+
+static void
 optimize_code (gfc_code *c)
 {
   for (; c; c = c->next)