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: simplify_replace_rtx, do not blindly replace regs


The following code in cse_insn makes substitutions inside libcalls:

              /* If we just made a substitution inside a libcall, then we
                 need to make the same substitution in any notes attached
                 to the RETVAL insn.  */

However, the call to simplify_replace_rtx() which follows, will change
a hard register without regard to its mode.  In one testcase, we end
up changing (reg:DI) into (reg:SI), which severely breaks cse later on.

One solution was to avoid substituting inside libcalls altogether.  Instead,
rth suggested narrowing down the condition in simplify_replace_rtx, as
below.

Tested on powerpc-linux.  OK for mainline and 3.4-e500 branch?

Aldy

	* simplify-rtx.c (simplify_replace_rtx): Do not blindly replace
	hard registers.

Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.215
diff -c -p -r1.215 simplify-rtx.c
*** simplify-rtx.c	13 Dec 2004 23:49:19 -0000	1.215
--- simplify-rtx.c	15 Dec 2004 16:45:55 -0000
*************** simplify_replace_rtx (rtx x, rtx old_rtx
*** 337,343 ****
  	}
        else if (code == REG)
  	{
! 	  if (REG_P (old_rtx) && REGNO (x) == REGNO (old_rtx))
  	    return new_rtx;
  	}
        break;
--- 337,343 ----
  	}
        else if (code == REG)
  	{
! 	  if (rtx_equal_p (x, old_rtx))
  	    return new_rtx;
  	}
        break;


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