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]

Patch to fix combine REG_NONNEG note distribution


The documentation for REG_NONNEG says:

  The register @var{op} is known to have a nonnegative value when this
  insn is reached.

However, distribute_notes has:

 	case REG_NONNEG:
  	...
  	  /* These notes say something about results of an insn.  We can
  	     only support them if they used to be on I3 in which case they

which can lead to REG_NONNEG being placed on i3 when it's no longer
valid.   A related problem is that recog_for_combine calls recog with
the old notes still attached to the insn which can cause a new pattern
to be recognized when it shouldn't.

This patch passes make bootstrap and make check on Compaq Tru64 UNIX 4.0f,
FreeBSD-3.4 x86, and Solaris 2.6 SPARC.

ChangeLog:

Fri Jun 16 00:55:02 EDT 2000  John Wehle  (john@feith.com)

	* combine.c (recog_for_combine): Remove the old notes
	prior to attempting to recognize the new pattern.
	(distribute_notes): Ignore REG_NONNEG notes.

Enjoy!

-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/combine.c.ORIGINAL	Wed Jun 14 03:32:02 2000
--- gcc/combine.c	Fri Jun 16 13:58:01 2000
*************** recog_for_combine (pnewpat, insn, pnotes
*** 9563,9568 ****
--- 9563,9569 ----
    int num_clobbers_to_add = 0;
    int i;
    rtx notes = 0;
+   rtx old_notes;
  
    /* If PAT is a PARALLEL, check to see if it contains the CLOBBER
       we use to indicate that something didn't match.  If we find such a
*************** recog_for_combine (pnewpat, insn, pnotes
*** 9573,9578 ****
--- 9574,9583 ----
  	  && XEXP (XVECEXP (pat, 0, i), 0) == const0_rtx)
  	return -1;
  
+   /* Remove the old notes prior to trying to recognize the new pattern.  */
+   old_notes = REG_NOTES (insn);
+   REG_NOTES (insn) = 0;
+ 
    /* Is the result of combination a valid instruction?  */
    insn_code_number = recog (pat, insn, &num_clobbers_to_add);
  
*************** recog_for_combine (pnewpat, insn, pnotes
*** 9602,9607 ****
--- 9607,9614 ----
        insn_code_number = recog (pat, insn, &num_clobbers_to_add);
      }
  
+   REG_NOTES (insn) = old_notes;
+ 
    /* If we had any clobbers to add, make a new pattern than contains
       them.  Then check to make sure that all of them are dead.  */
    if (num_clobbers_to_add)
*************** distribute_notes (notes, from_insn, i3, 
*** 12075,12081 ****
  
  	case REG_EQUAL:
  	case REG_EQUIV:
- 	case REG_NONNEG:
  	case REG_NOALIAS:
  	  /* These notes say something about results of an insn.  We can
  	     only support them if they used to be on I3 in which case they
--- 12082,12087 ----
*************** distribute_notes (notes, from_insn, i3, 
*** 12133,12141 ****
  	    }
  	  break;
  
  	case REG_WAS_0:
! 	  /* It is too much trouble to try to see if this note is still
! 	     correct in all situations.  It is better to simply delete it.  */
  	  break;
  
  	case REG_RETVAL:
--- 12139,12150 ----
  	    }
  	  break;
  
+ 	case REG_NONNEG:
  	case REG_WAS_0:
! 	  /* These notes say something about the value of a register prior
! 	     to the execution of an insn.  It is too much trouble to see
! 	     if the note is still correct in all situations.  It is better
! 	     to simply delete it.  */
  	  break;
  
  	case REG_RETVAL:
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------


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