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 incorrect uses of sets_cc0_p.


Current sets_cc0_p is used incorrectly in some places.

  1) It only handles a pattern, however it's sometimes passed an insn.

  2) Some places which are attempting to see if the CC0 setter can be
     deleted fail to check for side effects.

It passes make and check on mips-elf and powerpc-eabisim.

ChangeLog:

Fri Aug  3 15:54:16 EDT 2001  John Wehle  (john@feith.com)

	* rtl.h (only_sets_cc0_p): New prototype.
	* jump.c (sets_cc0_p): Handle INSN.
	(only_sets_cc0_p): New function.
	* flow.c (merge_blocks_nomove): Use only_sets_cc0_p.
	(tidy_fallthru_edge): Likewise.
	* integrate.c (copy_insn_list): Likewise.
	* unroll.c (unroll_loop): Likewise.
	(copy_loop_body): Likewise.

Enjoy!

-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/rtl.h.ORIGINAL	Mon Jul 30 15:42:06 2001
--- gcc/rtl.h	Thu Aug  2 15:34:22 2001
*************** extern rtx condjump_label		PARAMS ((rtx)
*** 1718,1723 ****
--- 1718,1724 ----
  extern int simplejump_p			PARAMS ((rtx));
  extern int returnjump_p			PARAMS ((rtx));
  extern int onlyjump_p			PARAMS ((rtx));
+ extern int only_sets_cc0_p		PARAMS ((rtx));
  extern int sets_cc0_p			PARAMS ((rtx));
  extern int invert_jump_1		PARAMS ((rtx, rtx));
  extern int invert_jump			PARAMS ((rtx, rtx, int));
*** gcc/jump.c.ORIGINAL	Wed Aug  1 16:41:52 2001
--- gcc/jump.c	Fri Aug  3 02:27:04 2001
*************** onlyjump_p (insn)
*** 1265,1270 ****
--- 1265,1287 ----
  
  #ifdef HAVE_cc0
  
+ /* Return non-zero if X is an RTX that only sets the condition codes
+    and has no side effects.  */
+ 
+ int
+ only_sets_cc0_p (x)
+      rtx x;
+ {
+ 
+   if (! x)
+     return 0;
+ 
+   if (INSN_P (x))
+     x = PATTERN (x);
+ 
+   return sets_cc0_p (x) == 1 && ! side_effects_p (x);
+ }
+ 
  /* Return 1 if X is an RTX that does nothing but set the condition codes
     and CLOBBER or USE registers.
     Return -1 if X does explicitly set the condition codes,
*************** onlyjump_p (insn)
*** 1272,1279 ****
  
  int
  sets_cc0_p (x)
!      rtx x ATTRIBUTE_UNUSED;
  {
    if (GET_CODE (x) == SET && SET_DEST (x) == cc0_rtx)
      return 1;
    if (GET_CODE (x) == PARALLEL)
--- 1289,1303 ----
  
  int
  sets_cc0_p (x)
!      rtx x;
  {
+ 
+   if (! x)
+     return 0;
+ 
+   if (INSN_P (x))
+     x = PATTERN (x);
+ 
    if (GET_CODE (x) == SET && SET_DEST (x) == cc0_rtx)
      return 1;
    if (GET_CODE (x) == PARALLEL)
*** gcc/flow.c.ORIGINAL	Wed Aug  1 16:41:52 2001
--- gcc/flow.c	Fri Aug  3 02:39:08 2001
*************** merge_blocks_nomove (a, b)
*** 2934,2940 ****
  #ifdef HAVE_cc0
        /* If this was a conditional jump, we need to also delete
  	 the insn that set cc0.  */
!       if (prev && sets_cc0_p (prev))
  	{
  	  rtx tmp = prev;
  	  prev = prev_nonnote_insn (prev);
--- 2934,2940 ----
  #ifdef HAVE_cc0
        /* If this was a conditional jump, we need to also delete
  	 the insn that set cc0.  */
!       if (only_sets_cc0_p (prev))
  	{
  	  rtx tmp = prev;
  	  prev = prev_nonnote_insn (prev);
*************** tidy_fallthru_edge (e, b, c)
*** 4139,4145 ****
  #ifdef HAVE_cc0
        /* If this was a conditional jump, we need to also delete
  	 the insn that set cc0.  */
!       if (any_condjump_p (q) && sets_cc0_p (PREV_INSN (q)))
  	q = PREV_INSN (q);
  #endif
  
--- 4139,4145 ----
  #ifdef HAVE_cc0
        /* If this was a conditional jump, we need to also delete
  	 the insn that set cc0.  */
!       if (any_condjump_p (q) && only_sets_cc0_p (PREV_INSN (q)))
  	q = PREV_INSN (q);
  #endif
  
*** gcc/integrate.c.ORIGINAL	Thu Jul 26 18:48:16 2001
--- gcc/integrate.c	Fri Aug  3 02:32:36 2001
*************** copy_insn_list (insns, map, static_chain
*** 1463,1469 ****
  	    {
  #ifdef HAVE_cc0
  	      /* If the previous insn set cc0 for us, delete it.  */
! 	      if (sets_cc0_p (PREV_INSN (copy)))
  		delete_insn (PREV_INSN (copy));
  #endif
  
--- 1463,1469 ----
  	    {
  #ifdef HAVE_cc0
  	      /* If the previous insn set cc0 for us, delete it.  */
! 	      if (only_sets_cc0_p (PREV_INSN (copy)))
  		delete_insn (PREV_INSN (copy));
  #endif
  
*** gcc/unroll.c.ORIGINAL	Thu Jul 26 18:48:18 2001
--- gcc/unroll.c	Fri Aug  3 02:29:58 2001
*************** unroll_loop (loop, insn_count, strength_
*** 378,384 ****
  #ifdef HAVE_cc0
  	  /* The immediately preceding insn may be a compare which must be
  	     deleted.  */
! 	  if (sets_cc0_p (prev))
  	    delete_insn (prev);
  #endif
  	}
--- 378,384 ----
  #ifdef HAVE_cc0
  	  /* The immediately preceding insn may be a compare which must be
  	     deleted.  */
! 	  if (only_sets_cc0_p (prev))
  	    delete_insn (prev);
  #endif
  	}
*************** copy_loop_body (loop, copy_start, copy_e
*** 2147,2153 ****
  	    {
  #ifdef HAVE_cc0
  	      /* If the previous insn set cc0 for us, delete it.  */
! 	      if (sets_cc0_p (PREV_INSN (copy)))
  		delete_insn (PREV_INSN (copy));
  #endif
  
--- 2147,2153 ----
  	    {
  #ifdef HAVE_cc0
  	      /* If the previous insn set cc0 for us, delete it.  */
! 	      if (only_sets_cc0_p (PREV_INSN (copy)))
  		delete_insn (PREV_INSN (copy));
  #endif
  
-------------------------------------------------------------------------
|   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]