This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: reload CSE optimization
- To: John Carr <jfc at mit dot edu>, egcs at cygnus dot com, egcs-patches at cygnus dot com
- Subject: Re: reload CSE optimization
- From: Richard Henderson <rth at cygnus dot com>
- Date: Tue, 9 Jun 1998 18:53:08 -0700
- References: <199806081825.OAA07957@jfc.>
- Reply-To: Richard Henderson <rth at cygnus dot com>
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++)
{