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 useless REG_EQUAL notes


This patch is another attempt to reduce the number of unnecessary
REG_EQUAL notes that litter GCC's RTL.

On x86, the following short program

int var;

short foo()
{
  return (short)var;
}

generates RTL that includes the instruction

(insn 11 9 13 (set (reg/f:SI 60)
        (symbol_ref:SI ("var"))) -1 (nil)
    (expr_list:REG_EQUAL (symbol_ref:SI ("var"))
        (nil)))

Clearly, once again, the REG_EQUAL note is just duplicating the
source of the set and therefore conveys no additional information
to GCC's RTL optimizers.  Avoiding this note uses less memory and
potentially speeds up the compiler.


The following patch has been tested on i686-pc-linux-gnu with a
full "make bootstrap", all languages except Ada and treelang, and
regression tested with "make -k check" with no new failures.

Ok for mainline?


2003-02-20  Roger Sayle  <roger at eyesopen dot com>

	* explow.c (force_reg): Avoid useless REG_EQUAL notes.


Index: explow.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/explow.c,v
retrieving revision 1.105
diff -c -3 -p -r1.105 explow.c
*** explow.c	16 Dec 2002 18:19:25 -0000	1.105
--- explow.c	20 Feb 2003 04:35:54 -0000
*************** force_reg (mode, x)
*** 775,781 ****
       if INSN set something else (such as a SUBREG of TEMP).  */
    if (CONSTANT_P (x)
        && (set = single_set (insn)) != 0
!       && SET_DEST (set) == temp)
      set_unique_reg_note (insn, REG_EQUAL, x);

    return temp;
--- 775,782 ----
       if INSN set something else (such as a SUBREG of TEMP).  */
    if (CONSTANT_P (x)
        && (set = single_set (insn)) != 0
!       && SET_DEST (set) == temp
!       && ! rtx_equal_p (x, SET_SRC (set)))
      set_unique_reg_note (insn, REG_EQUAL, x);

    return temp;

Roger
--
Roger Sayle,                         E-mail: roger at eyesopen dot 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]