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]

Re: reload CSE optimization


On Mon, Jun 08, 1998 at 02:25:42PM -0400, John Carr wrote:
> 
> Reload CSE should not replace a CONST_INT with a REG unless the REG is
> cheaper.  If they are equal cost other considerations make the original
> form preferable (scheduling, human comprehension, and the principle that
> one should avoid making changes with no benefit).

There is an additional place this should be checked.


r~


Index: reload1.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/reload1.c,v
retrieving revision 1.37
diff -c -p -d -r1.37 reload1.c
*** reload1.c	1998/06/06 09:25:15	1.37
--- reload1.c	1998/06/10 01:49:26
*************** reload_cse_simplify_set (set, insn)
*** 8475,8486 ****
  
    dclass = REGNO_REG_CLASS (dreg);
  
!   /* If memory loads are cheaper than register copies, don't change
!      them.  */
    if (GET_CODE (src) == MEM
        && MEMORY_MOVE_COST (GET_MODE (src), dclass, 1) < 2)
      return 0;
  
    dest_mode = GET_MODE (SET_DEST (set));
    for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
      {
--- 8474,8489 ----
  
    dclass = REGNO_REG_CLASS (dreg);
  
!   /* If memory loads are cheaper than register copies, don't change them.  */
    if (GET_CODE (src) == MEM
        && MEMORY_MOVE_COST (GET_MODE (src), dclass, 1) < 2)
      return 0;
  
+   /* If the constant is cheaper than a register, don't change it.  */
+   if (CONSTANT_P (src)
+       && rtx_cost (src, SET) < 2)
+     return 0;
+ 
    dest_mode = GET_MODE (SET_DEST (set));
    for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
      {


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