[RFC] gfc_* optimization pass for Fortran

Submitted by Thomas Koenig on July 16, 2010, 8:04 p.m.

Details

Message ID 1279310681.9566.6.camel@linux-fd1f.site
State New
Headers show

Commit Message

Thomas Koenig July 16, 2010, 8:04 p.m.
Hello world,

here is an attempt at an optimization pass for Fortran based on gfc_*
data structures.  It adds a new file, optimize.c.  Optimizations are
only performed if the user specifies -O.

Right now, the actual optimizations performed are few - it replaces
comparisons of varaibles with themselves with .true. and strips
off TRIM from string comparisons and assingments.

This does not yet regtest cleanly.

Comments?  Is this the right approach?  Other ideas?

I'll add some test cases and a ChangeLog later, if the consensus is that
this should go ahead.

	Thomas

Patch hide | download patch | download mbox

Index: Make-lang.in
===================================================================
--- Make-lang.in	(Revision 161930)
+++ Make-lang.in	(Arbeitskopie)
@@ -66,7 +66,7 @@ 
     fortran/trans.o fortran/trans-array.o fortran/trans-common.o \
     fortran/trans-const.o fortran/trans-decl.o fortran/trans-expr.o \
     fortran/trans-intrinsic.o fortran/trans-io.o fortran/trans-openmp.o \
-    fortran/trans-stmt.o fortran/trans-types.o
+    fortran/trans-stmt.o fortran/trans-types.o fortran/optimize.o
 
 fortran_OBJS = $(F95_OBJS) gfortranspec.o
 
Index: gfortran.h
===================================================================
--- gfortran.h	(Revision 161930)
+++ gfortran.h	(Arbeitskopie)
@@ -2828,4 +2828,8 @@ 
 
 #define CLASS_DATA(sym) sym->ts.u.derived->components
 
+/* optimize.c */
+
+void gfc_optimize_namespace (gfc_namespace *);
+
 #endif /* GCC_GFORTRAN_H  */
Index: trans-decl.c
===================================================================
--- trans-decl.c	(Revision 161930)
+++ trans-decl.c	(Arbeitskopie)
@@ -4374,6 +4374,9 @@ 
   int rank;
   bool is_recursive;
 
+  if (optimize)
+    gfc_optimize_namespace (ns);
+
   sym = ns->proc_name;
 
   /* Check that the frontend isn't still using this.  */