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] cse (canon_reg): Don't modify insns without using validate_change


Hello,

this is in reply to http://gcc.gnu.org/ml/gcc/2006-05/msg00578.html
on gcc-devel list.

The attached patch removes the special cases in canon_reg where insns
where modified without validate_change. Although it should generally 
be possible to replace one pseudo with another the x86 and s390 back ends
(and maybe others) use the insn condition to impose contraints between
operands. Since it is not clearly stated in the manual and the back end
uses of such conditions seem to be pervasive Bernd Schmidt agreed to fix
this in cse for now.

Unfortunately I don't have a testcase in a language integrated in gcc.
And also the testcase I have turned out to be extremely fragile.

Bootstrapped on i686, s390 and s390x.
No testsuite regressions.

OK for mainline and 4.1?

Bye,

-Andreas-



2006-05-30  Andreas Krebbel  <krebbel1@de.ibm.com>

	* cse.c (validate_canon_reg, cse_insn): Don't change insns without
	calling recog.


Index: gcc/cse.c
===================================================================
*** gcc/cse.c.orig	2006-05-29 12:58:10.000000000 +0200
--- gcc/cse.c	2006-05-29 13:10:11.000000000 +0200
*************** static void
*** 2728,2744 ****
  validate_canon_reg (rtx *xloc, rtx insn)
  {
    rtx new = canon_reg (*xloc, insn);
-   int insn_code;
  
    /* If replacing pseudo with hard reg or vice versa, ensure the
       insn remains valid.  Likewise if the insn has MATCH_DUPs.  */
!   if (insn != 0 && new != 0
!       && REG_P (new) && REG_P (*xloc)
!       && (((REGNO (new) < FIRST_PSEUDO_REGISTER)
! 	   != (REGNO (*xloc) < FIRST_PSEUDO_REGISTER))
! 	  || GET_MODE (new) != GET_MODE (*xloc)
! 	  || (insn_code = recog_memoized (insn)) < 0
! 	  || insn_data[insn_code].n_dups > 0))
      validate_change (insn, xloc, new, 1);
    else
      *xloc = new;
--- 2728,2737 ----
  validate_canon_reg (rtx *xloc, rtx insn)
  {
    rtx new = canon_reg (*xloc, insn);
  
    /* If replacing pseudo with hard reg or vice versa, ensure the
       insn remains valid.  Likewise if the insn has MATCH_DUPs.  */
!   if (insn != 0 && new != 0)
      validate_change (insn, xloc, new, 1);
    else
      *xloc = new;
*************** cse_insn (rtx insn, rtx libcall_insn)
*** 4943,4959 ****
        rtx dest = SET_DEST (sets[i].rtl);
        rtx src = SET_SRC (sets[i].rtl);
        rtx new = canon_reg (src, insn);
-       int insn_code;
  
        sets[i].orig_src = src;
!       if ((REG_P (new) && REG_P (src)
! 	   && ((REGNO (new) < FIRST_PSEUDO_REGISTER)
! 	       != (REGNO (src) < FIRST_PSEUDO_REGISTER)))
! 	  || (insn_code = recog_memoized (insn)) < 0
! 	  || insn_data[insn_code].n_dups > 0)
! 	validate_change (insn, &SET_SRC (sets[i].rtl), new, 1);
!       else
! 	SET_SRC (sets[i].rtl) = new;
  
        if (GET_CODE (dest) == ZERO_EXTRACT)
  	{
--- 4936,4944 ----
        rtx dest = SET_DEST (sets[i].rtl);
        rtx src = SET_SRC (sets[i].rtl);
        rtx new = canon_reg (src, insn);
  
        sets[i].orig_src = src;
!       validate_change (insn, &SET_SRC (sets[i].rtl), new, 1);
  
        if (GET_CODE (dest) == ZERO_EXTRACT)
  	{


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