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]

regclass tweek


Hi
While looking on possibilities to eliminate that problems with union classes, I
spot another small problem here in copy_cost. It always computes costs in one
direction, while it should in both. Also we can use move_cost instead of
may_move* ones and kill one quite big global array.

The effect can be seen on testcase from previous mail:

int x;
float a,b,e;
test()
{
  float c=a, d=b;
  if (x)
	  c=d;
  e=a;
}



;; Function test



Pass 0

  Register 45 costs: AREG:0 DREG:0 CREG:0 BREG:0 SIREG:0 DIREG:0 AD_REGS:0 Q_REGS:0 NON_Q_REGS:10 INDEX_REGS:0 GENERAL_REGS:10 FP_TOP_REG:0 FP_SECOND_REG:0 FLOAT_REGS:0 FP_TOP_SSE_REGS:12 FP_SECOND_SSE_REGS:12 FLOAT_SSE_REGS:12 FLOAT_INT_REGS:0 INT_SSE_REGS:10 FLOAT_INT_SSE_REGS:12 ALL_REGS:12 MEM:4

  Register 45 pref FLOAT_INT_REGS or none


Pass 1

  Register 45 costs: AREG:0 DREG:0 CREG:0 BREG:0 SIREG:0 DIREG:0 AD_REGS:0 Q_REGS:0 NON_Q_REGS:10 INDEX_REGS:0 GENERAL_REGS:10 FP_TOP_REG:0 FP_SECOND_REG:0 FLOAT_REGS:0 FP_TOP_SSE_REGS:12 FP_SECOND_SSE_REGS:12 FLOAT_SSE_REGS:12 FLOAT_INT_REGS:0 INT_SSE_REGS:10 FLOAT_INT_SSE_REGS:12 ALL_REGS:12 MEM:4

46 registers.

Register 45 used 2 times across 4 insns in block 0; set 1 time; FLOAT_INT_REGS or none.



Honza

Thu Mar  1 19:45:34 CET 2001  Jan Hubicka  <jh@suse.cz>
	* regclass.c (move_cost): Remove global variable.
	(init_reg_sets_1): Add move_cost local variable.
	(copy_cost): Use may_move_cost.
Index: regclass.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/regclass.c,v
retrieving revision 1.116
diff -c -3 -p -r1.116 regclass.c
*** regclass.c	2001/02/19 15:50:20	1.116
--- regclass.c	2001/03/01 18:41:26
*************** enum machine_mode reg_raw_mode[FIRST_PSE
*** 179,191 ****
  static char contains_reg_of_mode [N_REG_CLASSES] [MAX_MACHINE_MODE];
  
  /* Maximum cost of moving from a register in one class to a register in
!    another class.  Based on REGISTER_MOVE_COST.  */
  
- static int move_cost[MAX_MACHINE_MODE][N_REG_CLASSES][N_REG_CLASSES];
- 
- /* Similar, but here we don't have to move if the first index is a subset
-    of the second so in that case the cost is zero.  */
- 
  static int may_move_in_cost[MAX_MACHINE_MODE][N_REG_CLASSES][N_REG_CLASSES];
  
  /* Similar, but here we don't have to move if the first index is a superset
--- 179,188 ----
  static char contains_reg_of_mode [N_REG_CLASSES] [MAX_MACHINE_MODE];
  
  /* Maximum cost of moving from a register in one class to a register in
!    another class.  Based on REGISTER_MOVE_COST.  
!    If the first index is a subset of the second so in that case the cost
!    is zero.  */
  
  static int may_move_in_cost[MAX_MACHINE_MODE][N_REG_CLASSES][N_REG_CLASSES];
  
  /* Similar, but here we don't have to move if the first index is a superset
*************** init_reg_sets_1 ()
*** 293,298 ****
--- 290,296 ----
    register unsigned int i, j;
    register unsigned int /* enum machine_mode */ m;
    char allocatable_regs_of_mode [MAX_MACHINE_MODE];
+   int move_cost[MAX_MACHINE_MODE][N_REG_CLASSES][N_REG_CLASSES];
  
    /* This macro allows the fixed or call-used registers
       and the register classes to depend on target flags.  */
*************** copy_cost (x, mode, class, to_p)
*** 1837,1853 ****
  
  #ifdef SECONDARY_INPUT_RELOAD_CLASS
    if (to_p == 1)
!     secondary_class = SECONDARY_INPUT_RELOAD_CLASS (class, mode, x);
  #endif
  
  #ifdef SECONDARY_OUTPUT_RELOAD_CLASS
    if (! to_p)
!     secondary_class = SECONDARY_OUTPUT_RELOAD_CLASS (class, mode, x);
  #endif
- 
-   if (secondary_class != NO_REGS)
-     return (move_cost[mode][(int) secondary_class][(int) class]
- 	    + copy_cost (x, mode, secondary_class, 2));
  #endif  /* HAVE_SECONDARY_RELOADS */
  
    /* For memory, use the memory move cost, for (hard) registers, use the
--- 1839,1861 ----
  
  #ifdef SECONDARY_INPUT_RELOAD_CLASS
    if (to_p == 1)
!     {
!       secondary_class = SECONDARY_INPUT_RELOAD_CLASS (class, mode, x);
!       if (secondary_class != NO_REGS)
! 	return (may_move_in_cost[mode][(int) secondary_class][(int) class]
! 		+ copy_cost (x, mode, secondary_class, 2));
!     }
  #endif
  
  #ifdef SECONDARY_OUTPUT_RELOAD_CLASS
    if (! to_p)
!     {
!       secondary_class = SECONDARY_OUTPUT_RELOAD_CLASS (class, mode, x);
!       if (secondary_class != NO_REGS)
! 	return (may_move_out_cost[mode][(int) class][(int) secondary_class]
! 		+ copy_cost (x, mode, secondary_class, 0));
!     }
  #endif
  #endif  /* HAVE_SECONDARY_RELOADS */
  
    /* For memory, use the memory move cost, for (hard) registers, use the
*************** copy_cost (x, mode, class, to_p)
*** 1858,1864 ****
      return MEMORY_MOVE_COST (mode, class, to_p);
  
    else if (GET_CODE (x) == REG)
!     return move_cost[mode][(int) REGNO_REG_CLASS (REGNO (x))][(int) class];
  
    else
      /* If this is a constant, we may eventually want to call rtx_cost here.  */
--- 1866,1876 ----
      return MEMORY_MOVE_COST (mode, class, to_p);
  
    else if (GET_CODE (x) == REG)
!     {
!       if (to_p)
! 	return may_move_in_cost[mode][(int) REGNO_REG_CLASS (REGNO (x))][(int) class];
!       return may_move_out_cost[mode][(int) class][(int) REGNO_REG_CLASS (REGNO (x))];
!     }
  
    else
      /* If this is a constant, we may eventually want to call rtx_cost here.  */


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