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]

rtx_cost versus SUBREG tweeks


Hi,
the cse uses notreg_cost before calling rtx_cost, while other places
calls rtx_cost directly.

Only difference seems to be for SUBREGs, that are set by notreg_cost
to cost 0 (equivalent to registers).
I don't see any purpose for this difference, so this patch removes
the function and updates rtx_cost.

There don't seems to me differences in resulting code (except the
fact that I will have easier work in future changes of gcse)

Honza

Mon Jun  4 18:26:37 CEST 2001  Jan Hubicka   <jh@suse.cz>
	* cse.c (COST, COST_IN): Use rtx_cost instead of notreg_cost.
	(notreg_cost): Kill.
	(rtx_cost): Recognize proper SUBREGs and set their cost to 0.

Index: cse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cse.c,v
retrieving revision 1.186
diff -c -3 -p -r1.186 cse.c
*** cse.c	2001/05/17 18:46:57	1.186
--- cse.c	2001/06/04 16:26:19
*************** struct table_elt
*** 505,512 ****
     || ((N) < FIRST_PSEUDO_REGISTER					\
         && FIXED_REGNO_P (N) && REGNO_REG_CLASS (N) != NO_REGS))
  
! #define COST(X) (GET_CODE (X) == REG ? 0 : notreg_cost (X, SET))
! #define COST_IN(X,OUTER) (GET_CODE (X) == REG ? 0 : notreg_cost (X, OUTER))
  
  /* Get the info associated with register N.  */
  
--- 505,512 ----
     || ((N) < FIRST_PSEUDO_REGISTER					\
         && FIXED_REGNO_P (N) && REGNO_REG_CLASS (N) != NO_REGS))
  
! #define COST(X) (GET_CODE (X) == REG ? 0 : rtx_cost (X, SET) * 2)
! #define COST_IN(X,OUTER) (GET_CODE (X) == REG ? 0 : rtx_cost (X, OUTER) * 2)
  
  /* Get the info associated with register N.  */
  
*************** struct cse_basic_block_data
*** 640,646 ****
  	   || XEXP (X, 0) == virtual_outgoing_args_rtx))	\
     || GET_CODE (X) == ADDRESSOF)
  
- static int notreg_cost		PARAMS ((rtx, enum rtx_code));
  static int approx_reg_cost_1	PARAMS ((rtx *, void *));
  static int approx_reg_cost	PARAMS ((rtx));
  static int preferrable		PARAMS ((int, int, int, int));
--- 640,645 ----
*************** preferrable (cost_a, regcost_a, cost_b, 
*** 800,826 ****
    return 0;
  }
  
- /* Internal function, to compute cost when X is not a register; called
-    from COST macro to keep it simple.  */
- 
- static int
- notreg_cost (x, outer)
-      rtx x;
-      enum rtx_code outer;
- {
-   return ((GET_CODE (x) == SUBREG
- 	   && GET_CODE (SUBREG_REG (x)) == REG
- 	   && GET_MODE_CLASS (GET_MODE (x)) == MODE_INT
- 	   && GET_MODE_CLASS (GET_MODE (SUBREG_REG (x))) == MODE_INT
- 	   && (GET_MODE_SIZE (GET_MODE (x))
- 	       < GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
- 	   && subreg_lowpart_p (x)
- 	   && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE (x)),
- 				     GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (x)))))
- 	  ? 0
- 	  : rtx_cost (x, outer) * 2);
- }
- 
  /* Return an estimate of the cost of computing rtx X.
     One use is in cse, to decide which expression to keep in the hash table.
     Another is in rtl generation, to pick the cheapest way to multiply.
--- 799,804 ----
*************** rtx_cost (x, outer_code)
*** 879,884 ****
--- 857,873 ----
        if (! MODES_TIEABLE_P (GET_MODE (x), GET_MODE (SUBREG_REG (x))))
  	return COSTS_N_INSNS (2
  			      + GET_MODE_SIZE (GET_MODE (x)) / UNITS_PER_WORD);
+       /* In case this is just SUBREG of register we can use as register, make
+ 	 it's cost 0.  */
+       if (GET_CODE (SUBREG_REG (x)) == REG
+ 	  && GET_MODE_CLASS (GET_MODE (x)) == MODE_INT
+ 	  && GET_MODE_CLASS (GET_MODE (SUBREG_REG (x))) == MODE_INT
+ 	  && (GET_MODE_SIZE (GET_MODE (x))
+ 	      < GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
+ 	  && subreg_lowpart_p (x)
+ 	  && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE (x)),
+ 				    GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (x)))))
+ 	return 0;
        break;
  
  #ifdef RTX_COSTS


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