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]

cse.c fix



Hi,
this patch fixes bug in delete_trivially_dead_insns.  I sent the patch some time
ago, but it didn't get approved and I found the diff again in the cfg branch
tree.

The problem is that dead_libcall_p may replace libcall with an single instruciotn.
The instruction may have different amount of registers and if it gets removed
in next iteration of the main loop, the counts may drop to zero even when they should
not.

Honza

Sun May  5 23:31:29 CEST 2002  Jan Hubicka  <jh@suse.cz>
	* cse.c (dead_libcall_p): Update counts.
	(delete_trivially_dead_insns): Update call of dead_libcall_p.
Index: cse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cse.c,v
retrieving revision 1.222
retrieving revision 1.212.2.10
diff -c -3 -p -r1.222 -r1.212.2.10
*** cse.c	22 Apr 2002 23:22:33 -0000	1.222
--- cse.c	24 Apr 2002 15:42:32 -0000	1.212.2.10
*************** static int check_dependence	PARAMS ((rtx
*** 691,697 ****
  static void flush_hash_table	PARAMS ((void));
  static bool insn_live_p		PARAMS ((rtx, int *));
  static bool set_live_p		PARAMS ((rtx, rtx, int *));
! static bool dead_libcall_p	PARAMS ((rtx));
  
  /* Dump the expressions in the equivalence class indicated by CLASSP.
     This function is used only for debugging.  */
--- 691,697 ----
  static void flush_hash_table	PARAMS ((void));
  static bool insn_live_p		PARAMS ((rtx, int *));
  static bool set_live_p		PARAMS ((rtx, rtx, int *));
! static bool dead_libcall_p	PARAMS ((rtx, int *));
  
  /* Dump the expressions in the equivalence class indicated by CLASSP.
     This function is used only for debugging.  */
*************** insn_live_p (insn, counts)
*** 7570,7577 ****
  /* Return true if libcall is dead as a whole.  */
  
  static bool
! dead_libcall_p (insn)
       rtx insn;
  {
    rtx note;
    /* See if there's a REG_EQUAL note on this insn and try to
--- 7570,7578 ----
  /* Return true if libcall is dead as a whole.  */
  
  static bool
! dead_libcall_p (insn, counts)
       rtx insn;
+      int *counts;
  {
    rtx note;
    /* See if there's a REG_EQUAL note on this insn and try to
*************** dead_libcall_p (insn)
*** 7588,7598 ****
--- 7589,7605 ----
        if (!new)
  	new = XEXP (note, 0);
  
+       /* While changing insn, we must update the counts accordingly.  */
+       count_reg_usage (insn, counts, NULL_RTX, -1);
+ 
        if (set && validate_change (insn, &SET_SRC (set), new, 0))
  	{
+           count_reg_usage (insn, counts, NULL_RTX, 1);
  	  remove_note (insn, find_reg_note (insn, REG_RETVAL, NULL_RTX));
+ 	  remove_note (insn, note);
  	  return true;
  	}
+        count_reg_usage (insn, counts, NULL_RTX, 1);
      }
    return false;
  }
*************** delete_trivially_dead_insns (insns, nreg
*** 7651,7657 ****
  	    {
  	      in_libcall = 1;
  	      live_insn = 1;
! 	      dead_libcall = dead_libcall_p (insn);
  	    }
  	  else if (in_libcall)
  	    live_insn = ! dead_libcall;
--- 7658,7664 ----
  	    {
  	      in_libcall = 1;
  	      live_insn = 1;
! 	      dead_libcall = dead_libcall_p (insn, counts);
  	    }
  	  else if (in_libcall)
  	    live_insn = ! dead_libcall;


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