This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] Remove useless loop from alias.c


Hi,

This patch removes an expensive loop in alias.c:init_alias_analysis.
The comment before the loop already says it:

-     This loop may not be needed any longer now that the main loop does
-     a better job at propagating alias information.  */

Well, it's not needed as far as I can tell.  I've counted the number
of passes in this loop for ~600 preprocessed C and C++ files from GCC
itself, and there was *never* more than one pass, i.e. nothing changed
in the loop So even if this is still a useful loop, it's questionable
whether the cost/benefit ratio justifies keeping the loop.

I've done the same experiment with earlier GCCs (3.1, 3.2, 3.3, and
3.4) and, interestingly, even there, this extra loop never looped...
This loop was introduced when John Carr's alias patch was imported
into egcs.  I didn't know how to dig further into history to find
out if there ever was a reason for having this loop.

So I suggest we remove the loop.

Bootstrapped&tested on i686-suse-linux-gnu (hi Ping-Hui, first post
from your machine!).  OK for the trunk?

Gr.
Steven


	* alias.c (init_alias_analysis): Remove simplification loop
	after propagating pointers.

Index: alias.c
===================================================================
--- alias.c	(revision 119207)
+++ alias.c	(working copy)
@@ -2586,38 +2586,6 @@ init_alias_analysis (void)
     if (reg_known_value[i] == 0)
       reg_known_value[i] = regno_reg_rtx[i + FIRST_PSEUDO_REGISTER];
 
-  /* Simplify the reg_base_value array so that no register refers to
-     another register, except to special registers indirectly through
-     ADDRESS expressions.
-
-     In theory this loop can take as long as O(registers^2), but unless
-     there are very long dependency chains it will run in close to linear
-     time.
-
-     This loop may not be needed any longer now that the main loop does
-     a better job at propagating alias information.  */
-  pass = 0;
-  do
-    {
-      changed = 0;
-      pass++;
-      for (ui = 0; ui < maxreg; ui++)
-	{
-	  rtx base = VEC_index (rtx, reg_base_value, ui);
-	  if (base && REG_P (base))
-	    {
-	      unsigned int base_regno = REGNO (base);
-	      if (base_regno == ui)		/* register set from itself */
-		VEC_replace (rtx, reg_base_value, ui, 0);
-	      else
-		VEC_replace (rtx, reg_base_value, ui,
-			     VEC_index (rtx, reg_base_value, base_regno));
-	      changed = 1;
-	    }
-	}
-    }
-  while (changed && pass < MAX_ALIAS_LOOP_PASSES);
-
   /* Clean up.  */
   free (new_reg_base_value);
   new_reg_base_value = 0;


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