Speedup invalid_mode_change_p

Segher Boessenkool segher@koffie.nl
Tue Mar 4 02:34:00 GMT 2003


Jan Hubicka wrote:
> Hi,
> this patch saves 5-10% of nonoptimizing combine.c compilation time.
> I will try to figure out from where the zillions of
> invalid_mode_change_p comes from and cut this down as an followup too.

Sorry for replying so late; I wrote the attached patch a week
or so ago.  It saves 5-15% time on -O0 compilations (on PowerPC).

invalid_mode_change_p() was called in a loop that finds the
closed union of all valid classes with the best score.  This
patch changes that to computing the closed union of *all*
classes with best score, and seeing if that is valid; if so,
we have a winner; if not, fall back to using the old loop.

Bootstrapped on ppc-unknown-linux-gnu (in a heavily modified
3.3 tree).  Not regtested due to lack of resources.  Jan, could
you please test it and commit if okay?


Segher




2003-03-04  Segher Boessenkool  <segher@koffie.nl>

	* regclass.c (regclass): Try first if the subunion of
	all best classes is allowed, and if so, use it, instead
	of always computing the subunion of allowed best classes.



--- regclass.c~	Sat Mar  1 04:01:12 2003
+++ regclass.c	Sat Mar  1 04:03:08 2003
*************** regclass (f, nregs, dump)
*** 1284,1289 ****
--- 1284,1317 ----
    	  if (optimize && !REG_N_REFS (i) && !REG_N_SETS (i))
    	    continue;

+ 	  /* Try the common case (that is, all cheapest classes are
+ 	     allowed) first.  */
+
+ 	  for (class = 1; class < (int) ALL_REGS; class++)
+ 	    {
+ 	      if (p->cost[class] < best_cost)
+ 		{
+ 		  best_cost = p->cost[class];
+ 		  best = (enum reg_class) class;
+ 		}
+ 	      else if (p->cost[class] == best_cost)
+ 		best = reg_class_subunion[(int) best][class];
+ 	    }
+ 	  if (!contains_reg_of_mode[(int) best][PSEUDO_REGNO_MODE (i)]
+ #ifdef FORBIDDEN_INC_DEC_CLASSES
+ 	      || (in_inc_dec[i] && forbidden_inc_dec_class[(int) best])
+ #endif
+ #ifdef CANNOT_CHANGE_MODE_CLASS
+ 	      || invalid_mode_change_p (i, best, PSEUDO_REGNO_MODE (i))
+ #endif
+ 		  )
+ 		;
+ 	  else
+ 	    goto found_best;
+
+ 	  best_cost = (1 << (HOST_BITS_PER_INT - 2)) - 1;
+ 	  best = ALL_REGS;
+
    	  for (class = (int) ALL_REGS - 1; class > 0; class--)
    	    {
    	      /* Ignore classes that are too small for this operand or
*************** regclass (f, nregs, dump)
*** 1306,1311 ****
--- 1334,1341 ----
    	      else if (p->cost[class] == best_cost)
    		best = reg_class_subunion[(int) best][class];
    	    }
+
+ found_best:

    	  /* Record the alternate register class; i.e., a class for which
    	     every register in it is better than using memory.  If adding a





More information about the Gcc-patches mailing list