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 vs magic constants


When COSTS_N_INSNS was added to rtl.h, its definition was changed
from (x*2) to (x*4) for some reason.  In any case, it seems a good
excuse to get rid of a bushel of hard-coded numbers.



r~


        * calls.c (precompute_register_parameters): Use COSTS_N_INSNS, not 2.
        * cse.c (rtx_cost): Likewise.
        * optabls.c (expand_binop): Likewise.
        (expand_twoval_binop, prepare_cmp_insn): Likewise.
        * regclass.c (copy_cost): Likewise.
        * reload1.c (reload_cse_move2add): Likewise.

Index: calls.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/calls.c,v
retrieving revision 1.155
diff -c -p -d -r1.155 calls.c
*** calls.c	2000/09/07 01:17:00	1.155
--- calls.c	2000/09/15 02:52:32
*************** precompute_register_parameters (num_actu
*** 864,870 ****
  		|| (GET_CODE (args[i].value) == SUBREG
  		    && GET_CODE (SUBREG_REG (args[i].value)) == REG)))
  	    && args[i].mode != BLKmode
! 	    && rtx_cost (args[i].value, SET) > 2
  	    && ((SMALL_REGISTER_CLASSES && *reg_parm_seen)
  		|| preserve_subexpressions_p ()))
  	  args[i].value = copy_to_mode_reg (args[i].mode, args[i].value);
--- 864,870 ----
  		|| (GET_CODE (args[i].value) == SUBREG
  		    && GET_CODE (SUBREG_REG (args[i].value)) == REG)))
  	    && args[i].mode != BLKmode
! 	    && rtx_cost (args[i].value, SET) > COSTS_N_INSNS (1)
  	    && ((SMALL_REGISTER_CLASSES && *reg_parm_seen)
  		|| preserve_subexpressions_p ()))
  	  args[i].value = copy_to_mode_reg (args[i].mode, args[i].value);
Index: cse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cse.c,v
retrieving revision 1.159
diff -c -p -d -r1.159 cse.c
*** cse.c	2000/09/13 06:27:16	1.159
--- cse.c	2000/09/15 02:52:32
*************** rtx_cost (x, outer_code)
*** 860,866 ****
        total = 0;
        break;
      default:
!       total = 2;
      }
  
    switch (code)
--- 860,866 ----
        total = 0;
        break;
      default:
!       total = COSTS_N_INSNS (1);
      }
  
    switch (code)
Index: optabs.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/optabs.c,v
retrieving revision 1.77
diff -c -p -d -r1.77 optabs.c
*** optabs.c	2000/09/11 01:50:46	1.77
--- optabs.c	2000/09/15 02:52:32
*************** expand_binop (mode, binoptab, op0, op1, 
*** 635,645 ****
    /* If we are inside an appropriately-short loop and one operand is an
       expensive constant, force it into a register.  */
    if (CONSTANT_P (op0) && preserve_subexpressions_p ()
!       && rtx_cost (op0, binoptab->code) > 2)
      op0 = force_reg (mode, op0);
  
    if (CONSTANT_P (op1) && preserve_subexpressions_p ()
!       && ! shift_op && rtx_cost (op1, binoptab->code) > 2)
      op1 = force_reg (mode, op1);
  
    /* Record where to delete back to if we backtrack.  */
--- 635,645 ----
    /* If we are inside an appropriately-short loop and one operand is an
       expensive constant, force it into a register.  */
    if (CONSTANT_P (op0) && preserve_subexpressions_p ()
!       && rtx_cost (op0, binoptab->code) > COSTS_N_INSNS (1))
      op0 = force_reg (mode, op0);
  
    if (CONSTANT_P (op1) && preserve_subexpressions_p ()
!       && ! shift_op && rtx_cost (op1, binoptab->code) > COSTS_N_INSNS (1))
      op1 = force_reg (mode, op1);
  
    /* Record where to delete back to if we backtrack.  */
*************** expand_twoval_binop (binoptab, op0, op1,
*** 1876,1886 ****
    /* If we are inside an appropriately-short loop and one operand is an
       expensive constant, force it into a register.  */
    if (CONSTANT_P (op0) && preserve_subexpressions_p ()
!       && rtx_cost (op0, binoptab->code) > 2)
      op0 = force_reg (mode, op0);
  
    if (CONSTANT_P (op1) && preserve_subexpressions_p ()
!       && rtx_cost (op1, binoptab->code) > 2)
      op1 = force_reg (mode, op1);
  
    if (targ0)
--- 1876,1886 ----
    /* If we are inside an appropriately-short loop and one operand is an
       expensive constant, force it into a register.  */
    if (CONSTANT_P (op0) && preserve_subexpressions_p ()
!       && rtx_cost (op0, binoptab->code) > COSTS_N_INSNS (1))
      op0 = force_reg (mode, op0);
  
    if (CONSTANT_P (op1) && preserve_subexpressions_p ()
!       && rtx_cost (op1, binoptab->code) > COSTS_N_INSNS (1))
      op1 = force_reg (mode, op1);
  
    if (targ0)
*************** prepare_cmp_insn (px, py, pcomparison, s
*** 2956,2966 ****
    /* If we are inside an appropriately-short loop and one operand is an
       expensive constant, force it into a register.  */
    if (CONSTANT_P (x) && preserve_subexpressions_p ()
!       && rtx_cost (x, COMPARE) > 2)
      x = force_reg (mode, x);
  
    if (CONSTANT_P (y) && preserve_subexpressions_p ()
!       && rtx_cost (y, COMPARE) > 2)
      y = force_reg (mode, y);
  
  #ifdef HAVE_cc0
--- 2956,2966 ----
    /* If we are inside an appropriately-short loop and one operand is an
       expensive constant, force it into a register.  */
    if (CONSTANT_P (x) && preserve_subexpressions_p ()
!       && rtx_cost (x, COMPARE) > COSTS_N_INSNS (1))
      x = force_reg (mode, x);
  
    if (CONSTANT_P (y) && preserve_subexpressions_p ()
!       && rtx_cost (y, COMPARE) > COSTS_N_INSNS (1))
      y = force_reg (mode, y);
  
  #ifdef HAVE_cc0
Index: regclass.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/regclass.c,v
retrieving revision 1.105
diff -c -p -d -r1.105 regclass.c
*** regclass.c	2000/08/29 00:44:21	1.105
--- regclass.c	2000/09/15 02:52:32
*************** copy_cost (x, mode, class, to_p)
*** 1813,1819 ****
  
    else
      /* If this is a constant, we may eventually want to call rtx_cost here.  */
!     return 2;
  }
  
  /* Record the pseudo registers we must reload into hard registers
--- 1813,1819 ----
  
    else
      /* If this is a constant, we may eventually want to call rtx_cost here.  */
!     return COSTS_N_INSNS (1);
  }
  
  /* Record the pseudo registers we must reload into hard registers
Index: reload1.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/reload1.c,v
retrieving revision 1.227
diff -c -p -d -r1.227 reload1.c
*** reload1.c	2000/09/08 09:41:07	1.227
--- reload1.c	2000/09/15 02:52:32
*************** reload_cse_move2add (first)
*** 8941,8947 ****
  			success
  			  = validate_change (next, &SET_SRC (set), reg, 0);
  		      else if ((rtx_cost (new_src, PLUS)
! 				< 2 + rtx_cost (src3, SET))
  			       && have_add2_insn (GET_MODE (reg)))
  			success
  			  = validate_change (next, &PATTERN (next),
--- 8941,8947 ----
  			success
  			  = validate_change (next, &SET_SRC (set), reg, 0);
  		      else if ((rtx_cost (new_src, PLUS)
! 				< COSTS_N_INSNS (1) + rtx_cost (src3, SET))
  			       && have_add2_insn (GET_MODE (reg)))
  			success
  			  = validate_change (next, &PATTERN (next),

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