This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, fortran, committed] Fix regression PR 48412


Hello world,

I have committed the attached patch to trunk as obvious after regression-testing. The problem was that the assignment statements had been added in the wrong order, which was fixed by reversing the order of the loops looking for common function calls in cfe_expr_0.

Many thanks to Joost for finding the bug in the first place and for reducing that far!

Thomas

2011-04-04 Thomas Koenig <tkoenig@gcc.gnu.org>

        PR fortran/48412
        * frontend-passes (cfe_expr_0):  Reverse the order of going
        through the loops.

2011-04-04 Thomas Koenig <tkoenig@gcc.gnu.org>

        PR fortran/48412
        * function_optimize_4.f90:  New test.
Index: frontend-passes.c
===================================================================
--- frontend-passes.c	(Revision 171913)
+++ frontend-passes.c	(Arbeitskopie)
@@ -295,16 +295,16 @@ cfe_expr_0 (gfc_expr **e, int *walk_subtrees,
 
   gfc_expr_walker (e, cfe_register_funcs, NULL);
 
-  /* Walk backwards through all the functions to make sure we
-     catch the leaf functions first.  */
-  for (i=expr_count-1; i>=1; i--)
+  /* Walk through all the functions.  */
+
+  for (i=1; i<expr_count; i++)
     {
       /* Skip if the function has been replaced by a variable already.  */
       if ((*(expr_array[i]))->expr_type == EXPR_VARIABLE)
 	continue;
 
       newvar = NULL;
-      for (j=i-1; j>=0; j--)
+      for (j=0; j<i; j++)
 	{
 	  if (gfc_dep_compare_functions(*(expr_array[i]),
 					*(expr_array[j]), true)	== 0)

Attachment: function_optimize_4.f90
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]