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]

gcse try_replace_reg tweek



Hi,
this patch makes try_replace_reg to replace FROM by TO in the insn
only if the result is cheaper.  This is consistent with what normal
CSE pass does and (togetehr with my previous change to CONST_COSTS
in i386.h) results in better code.

The try_replace_reg will still drop the REG_EQUAL note to expose
the knowledge to other passes.

Patch also fixes RTX sharing problem on REG_EQUAL notes.

Honza

Mon Jun  4 19:10:35 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* gcse.c (try_replace_reg): Use rtx_cost to avoid replacements
	making instruction more expensive.

Index: gcse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/gcse.c,v
retrieving revision 1.131
diff -c -3 -p -r1.131 gcse.c
*** gcse.c	2001/05/18 13:43:27	1.131
--- gcse.c	2001/06/04 17:05:43
*************** try_replace_reg (from, to, insn)
*** 3997,4003 ****
    int success = 0;
    rtx set = single_set (insn);
  
!   success = validate_replace_src (from, to, insn);
  
    /* If above failed and this is a single set, try to simplify the source of
       the set given our substitution.  We could perhaps try this for multiple
--- 3998,4007 ----
    int success = 0;
    rtx set = single_set (insn);
  
!   /* In case we are replacing by something equally expensive or cheaper,
!      try to globally replace in the insn.  */
!   if (rtx_cost (to, SET) <= rtx_cost (from, SET))
!     success = validate_replace_src (from, to, insn);
  
    /* If above failed and this is a single set, try to simplify the source of
       the set given our substitution.  We could perhaps try this for multiple
*************** try_replace_reg (from, to, insn)
*** 4007,4012 ****
--- 4011,4017 ----
        src = simplify_replace_rtx (SET_SRC (set), from, to);
  
        if (!rtx_equal_p (src, SET_SRC (set))
+ 	  && rtx_cost (src, SET) <= rtx_cost (SET_SRC (set), SET)
  	  && validate_change (insn, &SET_SRC (set), src, 0))
  	success = 1;
      }
*************** try_replace_reg (from, to, insn)
*** 4015,4021 ****
       have a note, add a REG_EQUAL note to not lose information.  */
    if (!success && note == 0 && set != 0)
      note = REG_NOTES (insn)
!       = gen_rtx_EXPR_LIST (REG_EQUAL, src, REG_NOTES (insn));
  
    /* If there is already a NOTE, update the expression in it with our
       replacement.  */
--- 4020,4026 ----
       have a note, add a REG_EQUAL note to not lose information.  */
    if (!success && note == 0 && set != 0)
      note = REG_NOTES (insn)
!       = gen_rtx_EXPR_LIST (REG_EQUAL, copy_rtx (src), REG_NOTES (insn));
  
    /* If there is already a NOTE, update the expression in it with our
       replacement.  */


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