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]
Other format: [Raw text]

[PATCH] Avoid redundant REG_EQUAL notes


The following patch attempts to minimize the number of useless
REG_EQUAL notes littering GCC's RTL.  For example, CSE has a
habit of creating RTL such as the following:

(insn 10 47 55 (set (reg/v:SI 59)
        (const_int 5 [0x5])) 45 {*movsi_1} (nil)
    (expr_list:REG_EQUAL (const_int 5 [0x5])
        (nil)))

where the REG_EQUAL note tells us nothing that the SET_SRC
of the insn doesn't already.

I'm currently investigating why some of GCC's optimizations get
applied on some targets and not others.  To cure one of these
failures, I'm investigating processing REG_EQUAL notes in GCC's
RTL optimizers, and to preempt any serious slow down, it makes
sense to improve the signal-to-noise ratio of REG_EQUAL notes.
Fewer notes means less RTL, means less memory fragmentation and
fewer GCs, so this patch has some merit all of its own.

The tweak to cse.c is to avoid storing a REG_EQUAL note on a
set instruction if the RTX in the note is the same as the src.

This patch has been tested on i686-pc-linux-gnu with a complete
bootstrap, all languages except Ada and treelang, and a full
"make -k check" with no new regressions.  I've also compared
several .s assembler files from before and after to ensure that
(on i686 atleast) we generate identically the same code with this
patch as we did before, even though the RTL dumps get smaller.


Ok for mainline?


2003-01-27  Roger Sayle  <roger@eyesopen.com>

	* cse.c (cse_insn): Avoid redundant REG_EQUAL notes.


Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.249
diff -c -3 -p -r1.249 cse.c
*** cse.c	25 Jan 2003 17:37:42 -0000	1.249
--- cse.c	27 Jan 2003 04:27:54 -0000
*************** cse_insn (insn, libcall_insn)
*** 5691,5702 ****
  		&& GET_CODE (XEXP (XEXP (src_const, 0), 0)) == LABEL_REF
  		&& GET_CODE (XEXP (XEXP (src_const, 0), 1)) == LABEL_REF))
  	{
! 	  /* Make sure that the rtx is not shared with any other insn.  */
! 	  src_const = copy_rtx (src_const);

! 	  /* Record the actual constant value in a REG_EQUAL note, making
! 	     a new one if one does not already exist.  */
! 	  set_unique_reg_note (insn, REG_EQUAL, src_const);

  	  /* If storing a constant value in a register that
  	     previously held the constant value 0,
--- 5691,5706 ----
  		&& GET_CODE (XEXP (XEXP (src_const, 0), 0)) == LABEL_REF
  		&& GET_CODE (XEXP (XEXP (src_const, 0), 1)) == LABEL_REF))
  	{
! 	  /* We only want a REG_EQUAL note if src_const != src.  */
! 	  if (! rtx_equal_p (src, src_const))
! 	    {
! 	      /* Make sure that the rtx is not shared.  */
! 	      src_const = copy_rtx (src_const);

! 	      /* Record the actual constant value in a REG_EQUAL note,
! 		 making a new one if one does not already exist.  */
! 	      set_unique_reg_note (insn, REG_EQUAL, src_const);
! 	    }

  	  /* If storing a constant value in a register that
  	     previously held the constant value 0,

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


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