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]

Re: Speedup invalid_mode_change_p


Jan Hubicka wrote:
Jan Hubicka wrote:

2003-03-04 Segher Boessenkool <segher at koffie dot 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.


Good thing is that we get best speed with both patches combined :)

Of course :)


Can you please update it to avoid the goto statement (simply put the
default loop into the body).

Updated version included.


Is goto not allowed in GCC at all? I like it better this way.

Well, there are some places goto is used, but it is usually in the switch statements and such beasts, not to simulate normal if conditional.

Well, we can discuss whether "goto" is a simulation of "else", or the other way around ;)

Also the default loop can be optimized
slightly by first checking that the cost is not greater than best_cost
we currently have.

Will look at it.

Hrm, I forgot about this.



Tested on powerpc-unknown-linux-gnu. If okay, please commit. (Same changelog as before).


Segher




*** regclass.c~	Sat Mar 22 03:22:15 2003
--- regclass.c	Sat Mar 22 03:25:55 2003
*************** regclass (f, nregs, dump)
*** 1294,1320 ****
  	  if (optimize && !REG_N_REFS (i) && !REG_N_SETS (i))
  	    continue;

! 	  for (class = (int) ALL_REGS - 1; class > 0; class--)
  	    {
! 	      /* Ignore classes that are too small for this operand or
! 		 invalid for an operand that was auto-incremented.  */
! 	      if (!contains_reg_of_mode [class][PSEUDO_REGNO_MODE (i)]
  #ifdef FORBIDDEN_INC_DEC_CLASSES
! 		  || (in_inc_dec[i] && forbidden_inc_dec_class[class])
  #endif
  #ifdef CANNOT_CHANGE_MODE_CLASS
! 		  || invalid_mode_change_p (i, (enum reg_class) class,
! 					    PSEUDO_REGNO_MODE (i))
  #endif
  		  )
! 		;
! 	      else 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];
  	    }

  	  /* Record the alternate register class; i.e., a class for which
--- 1294,1346 ----
  	  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
  		  )
! 	    {
! 	      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
! 		     invalid for an operand that was auto-incremented.  */
! 		  if (!contains_reg_of_mode [class][PSEUDO_REGNO_MODE (i)]
! #ifdef FORBIDDEN_INC_DEC_CLASSES
! 		      || (in_inc_dec[i] && forbidden_inc_dec_class[class])
! #endif
! #ifdef CANNOT_CHANGE_MODE_CLASS
! 		      || invalid_mode_change_p (i, (enum reg_class) class,
! 						PSEUDO_REGNO_MODE (i))
! #endif
! 		      )
! 		    ;
! 		  else 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];
  		}
  	    }

/* Record the alternate register class; i.e., a class for which



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