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]

patches applied to sh-elf-3_5-branch


I have replaced this patch:
http://gcc.gnu.org/ml/gcc-patches/2004-06/msg00229.html
with this one:
http://gcc.gnu.org/ml/gcc-patches/2004-06/msg00652.html

And have also applied these patches:

2004-05-17  J"orn Rennecke <joern.rennecke@superh.com>

        Back out this patch:
          2003-10-08  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
          PR optimization/12142
          * cse.c (count_reg_usage): In a SET with a REG SET_DEST, count the
          uses of the register in the SET_SRC.  Remove unnecessary argument.

        Replace it with this:
        * cse.c (count_reg_usage): In INSN, JUMP_INSN and CALL_INSN cases,
        if flag_non_call_exceptions is set and the insn may trap, pass
        pc_rtx as dest for recursion.
        In SET_SRC part of SET case, if dest is already set, pass it down
        unchanged.
http://gcc.gnu.org/ml/gcc-patches/2004-05/msg01037.html

2004-05-27  J"orn Rennecke <joern.rennecke@superh.com>

	* rtl.h (delete_trivially_dead_insns): Add third parameter.
	* cse.c (trivially_dead_nonlocal_regs): New variable.
	(note_dead_set): New function.
	(delete_trivially_dead_insns): Add third parameter, update_life_p.
	* passes.c,
	* cfgcleanup.c,
	* ra.c: Changed all callers.

Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.478
diff -p -u -r1.478 rtl.h
--- rtl.h	3 Jun 2004 12:07:43 -0000	1.478
+++ rtl.h	11 Jun 2004 18:20:46 -0000
@@ -2113,7 +2113,7 @@ extern int no_new_pseudos;
 extern int rtx_to_tree_code (enum rtx_code);
 
 /* In cse.c */
-extern int delete_trivially_dead_insns (rtx, int);
+extern int delete_trivially_dead_insns (rtx, int, int);
 #ifdef BUFSIZ
 extern int cse_main (rtx, int, int, FILE *);
 #endif
Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.301.2.1
diff -p -u -r1.301.2.1 cse.c
--- cse.c	11 Jun 2004 17:27:10 -0000	1.301.2.1
+++ cse.c	11 Jun 2004 18:20:47 -0000
@@ -7505,16 +7505,37 @@ dead_libcall_p (rtx insn, int *counts)
   return false;
 }
 
+static regset_head trivially_dead_nonlocal_regs;
+
+/* Called via note_stores.  */
+void
+note_dead_set (rtx dest, rtx pat, void *data)
+{
+  basic_block bb = data;
+
+  if ((GET_CODE (pat) == SET && set_noop_p (pat))
+      || GET_CODE (dest) != REG
+      || ! REGNO_REG_SET_P (bb->global_live_at_end, REGNO (dest)))
+    return;
+  SET_REGNO_REG_SET (&trivially_dead_nonlocal_regs, REGNO (dest));
+}
+
 /* Scan all the insns and delete any that are dead; i.e., they store a register
    that is never used or they copy a register to itself.
 
    This is used to remove insns made obviously dead by cse, loop or other
    optimizations.  It improves the heuristics in loop since it won't try to
    move dead invariants out of loops or make givs for dead quantities.  The
-   remaining passes of the compilation are also sped up.  */
+   remaining passes of the compilation are also sped up.
+
+   When UPDATE_LIFE_P is nonzero, when we remove the sets of a register
+   that is not referenced anymore, also remove it from the liveness
+   information of all basic blocks.  Note, unlike update_life_info,
+   delete_trivially_dead_insns can find registers are set outside a loop
+   and used to, but are no longer referenced in the loop.  */
 
 int
-delete_trivially_dead_insns (rtx insns, int nreg)
+delete_trivially_dead_insns (rtx insns, int nreg, int update_life_p)
 {
   int *counts;
   rtx insn, prev;
@@ -7522,6 +7543,12 @@ delete_trivially_dead_insns (rtx insns, 
   int ndead = 0, nlastdead, niterations = 0;
 
   timevar_push (TV_DELETE_TRIVIALLY_DEAD);
+
+  if (update_life_p)
+    INIT_REG_SET (&trivially_dead_nonlocal_regs);
+  if (update_life_p)
+    compute_bb_for_insn ();
+
   /* First count the number of times each register is used.  */
   counts = xcalloc (nreg, sizeof (int));
   for (insn = next_real_insn (insns); insn; insn = next_real_insn (insn))
@@ -7569,6 +7596,9 @@ delete_trivially_dead_insns (rtx insns, 
 
 	  if (! live_insn)
 	    {
+	      if (update_life_p)
+		note_stores (PATTERN (insn), note_dead_set,
+			     BLOCK_FOR_INSN (insn));
 	      count_reg_usage (insn, counts, NULL_RTX, -1);
 	      delete_insn_and_edges (insn);
 	      ndead++;
@@ -7587,6 +7617,19 @@ delete_trivially_dead_insns (rtx insns, 
     fprintf (dump_file, "Deleted %i trivially dead insns; %i iterations\n",
 	     ndead, niterations);
   /* Clean up.  */
+  if (update_life_p)
+    {
+      basic_block bb;
+
+      FOR_EACH_BB (bb)
+	{
+	  AND_COMPL_REG_SET (bb->global_live_at_start,
+			     &trivially_dead_nonlocal_regs);
+	  AND_COMPL_REG_SET (bb->global_live_at_end,
+			     &trivially_dead_nonlocal_regs);
+	}
+      CLEAR_REG_SET (&trivially_dead_nonlocal_regs);
+    }
   free (counts);
   timevar_pop (TV_DELETE_TRIVIALLY_DEAD);
   return ndead;
Index: passes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/passes.c,v
retrieving revision 2.17
diff -p -u -r2.17 passes.c
--- passes.c	30 May 2004 18:32:27 -0000	2.17
+++ passes.c	11 Jun 2004 18:20:47 -0000
@@ -575,7 +575,7 @@ rest_of_handle_new_regalloc (tree decl, 
 {
   int failure;
 
-  delete_trivially_dead_insns (insns, max_reg_num ());
+  delete_trivially_dead_insns (insns, max_reg_num (), 1);
   reg_alloc ();
 
   timevar_pop (TV_LOCAL_ALLOC);
@@ -824,7 +824,7 @@ rest_of_handle_gcse2 (tree decl, rtx ins
 
   gcse_after_reload_main (insns, dump_file);
   rebuild_jump_labels (insns);
-  delete_trivially_dead_insns (insns, max_reg_num ());
+  delete_trivially_dead_insns (insns, max_reg_num (), 1);
   close_dump_file (DFI_gcse2, print_rtl_with_bb, insns);
 
   ggc_collect ();
@@ -908,7 +908,7 @@ rest_of_handle_web (tree decl, rtx insns
   open_dump_file (DFI_web, decl);
   timevar_push (TV_WEB);
   web_main ();
-  delete_trivially_dead_insns (insns, max_reg_num ());
+  delete_trivially_dead_insns (insns, max_reg_num (), 0);
   cleanup_cfg (CLEANUP_EXPENSIVE);
 
   timevar_pop (TV_WEB);
@@ -1017,7 +1017,7 @@ rest_of_handle_jump_bypass (tree decl, r
     {
       rebuild_jump_labels (insns);
       cleanup_cfg (CLEANUP_EXPENSIVE);
-      delete_trivially_dead_insns (insns, max_reg_num ());
+      delete_trivially_dead_insns (insns, max_reg_num (), 0);
     }
 
   close_dump_file (DFI_bypass, print_rtl_with_bb, insns);
@@ -1124,7 +1124,7 @@ rest_of_handle_cse (tree decl, rtx insns
   if (purge_all_dead_edges (0))
     delete_unreachable_blocks ();
 
-  delete_trivially_dead_insns (insns, max_reg_num ());
+  delete_trivially_dead_insns (insns, max_reg_num (), 0);
 
   /* If we are not running more CSE passes, then we are no longer
      expecting CSE to be run.  But always rerun it in a cheap mode.  */
@@ -1157,7 +1157,7 @@ rest_of_handle_cse2 (tree decl, rtx insn
   cse_condition_code_reg ();
 
   purge_all_dead_edges (0);
-  delete_trivially_dead_insns (insns, max_reg_num ());
+  delete_trivially_dead_insns (insns, max_reg_num (), 0);
 
   if (tem)
     {
@@ -1184,7 +1184,7 @@ rest_of_handle_gcse (tree decl, rtx insn
 
   tem = gcse_main (insns, dump_file);
   rebuild_jump_labels (insns);
-  delete_trivially_dead_insns (insns, max_reg_num ());
+  delete_trivially_dead_insns (insns, max_reg_num (), 0);
 
   save_csb = flag_cse_skip_blocks;
   save_cfj = flag_cse_follow_jumps;
@@ -1198,7 +1198,7 @@ rest_of_handle_gcse (tree decl, rtx insn
       reg_scan (insns, max_reg_num (), 1);
       tem2 = cse_main (insns, max_reg_num (), 0, dump_file);
       purge_all_dead_edges (0);
-      delete_trivially_dead_insns (insns, max_reg_num ());
+      delete_trivially_dead_insns (insns, max_reg_num (), 0);
       timevar_pop (TV_CSE);
       cse_not_expected = !flag_rerun_cse_after_loop;
     }
@@ -1219,7 +1219,7 @@ rest_of_handle_gcse (tree decl, rtx insn
 	  reg_scan (insns, max_reg_num (), 1);
 	  tem2 = cse_main (insns, max_reg_num (), 0, dump_file);
 	  purge_all_dead_edges (0);
-	  delete_trivially_dead_insns (insns, max_reg_num ());
+	  delete_trivially_dead_insns (insns, max_reg_num (), 0);
 	  timevar_pop (TV_CSE);
 	}
     }
@@ -1267,7 +1267,7 @@ rest_of_handle_loop_optimize (tree decl,
 	 trivially dead.  We delete those instructions now in the
 	 hope that doing so will make the heuristics in loop work
 	 better and possibly speed up compilation.  */
-      delete_trivially_dead_insns (insns, max_reg_num ());
+      delete_trivially_dead_insns (insns, max_reg_num (), 0);
 
       /* The regscan pass is currently necessary as the alias
 	 analysis code depends on this information.  */
@@ -1277,7 +1277,7 @@ rest_of_handle_loop_optimize (tree decl,
   loop_optimize (insns, dump_file, do_unroll | do_prefetch);
 
   /* Loop can create trivially dead instructions.  */
-  delete_trivially_dead_insns (insns, max_reg_num ());
+  delete_trivially_dead_insns (insns, max_reg_num (), 0);
   close_dump_file (DFI_loop, print_rtl, insns);
   timevar_pop (TV_LOOP);
   find_basic_blocks (insns, max_reg_num (), dump_file);
@@ -1337,7 +1337,7 @@ rest_of_handle_loop2 (tree decl, rtx ins
   cfg_layout_finalize ();
 
   cleanup_cfg (CLEANUP_EXPENSIVE);
-  delete_trivially_dead_insns (insns, max_reg_num ());
+  delete_trivially_dead_insns (insns, max_reg_num (), 0);
   reg_scan (insns, max_reg_num (), 0);
   if (dump_file)
     dump_flow_info (dump_file);
@@ -1524,7 +1524,7 @@ rest_of_compilation (tree decl)
   reg_scan (insns, max_reg_num (), 0);
   rebuild_jump_labels (insns);
   find_basic_blocks (insns, max_reg_num (), dump_file);
-  delete_trivially_dead_insns (insns, max_reg_num ());
+  delete_trivially_dead_insns (insns, max_reg_num (), 0);
   if (dump_file)
     dump_flow_info (dump_file);
   cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP
Index: cfgcleanup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgcleanup.c,v
retrieving revision 1.117
diff -p -u -r1.117 cfgcleanup.c
--- cfgcleanup.c	3 Jun 2004 12:07:38 -0000	1.117
+++ cfgcleanup.c	11 Jun 2004 18:20:47 -0000
@@ -2044,6 +2044,7 @@ bool
 cleanup_cfg (int mode)
 {
   bool changed = false;
+  bool have_live_info = EXIT_BLOCK_PTR->global_live_at_start != NULL;
 
   timevar_push (TV_CLEANUP_CFG);
   if (delete_unreachable_blocks ())
@@ -2053,7 +2054,8 @@ cleanup_cfg (int mode)
 	 now to introduce more opportunities for try_optimize_cfg.  */
       if (!(mode & (CLEANUP_NO_INSN_DEL | CLEANUP_UPDATE_LIFE))
 	  && !reload_completed)
-	delete_trivially_dead_insns (get_insns(), max_reg_num ());
+	delete_trivially_dead_insns (get_insns(), max_reg_num (),
+				     have_live_info);
     }
 
   compact_blocks ();
@@ -2078,7 +2080,8 @@ cleanup_cfg (int mode)
 	       && (mode & CLEANUP_EXPENSIVE)
 	       && !reload_completed)
 	{
-	  if (!delete_trivially_dead_insns (get_insns(), max_reg_num ()))
+	  if (!delete_trivially_dead_insns (get_insns(), max_reg_num (),
+					    have_live_info))
 	    break;
 	}
       else
Index: ra.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra.c,v
retrieving revision 1.18
diff -p -u -r1.18 ra.c
--- ra.c	20 May 2004 11:45:25 -0000	1.18
+++ ra.c	11 Jun 2004 18:20:47 -0000
@@ -801,7 +801,7 @@ reg_alloc (void)
 	  /* And new insns.  */
 	  compute_bb_for_insn ();
 	  /* Some of them might be dead.  */
-	  delete_trivially_dead_insns (get_insns (), max_reg_num ());
+	  delete_trivially_dead_insns (get_insns (), max_reg_num (), 1);
 	  /* Those new pseudos need to have their REFS count set.  */
 	  reg_scan_update (get_insns (), NULL, max_regno);
 	  max_regno = max_reg_num ();


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