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] Simple (for once) cleanups of combine


This patch includes two unrelated cleanups of combine.

1) combine used to create USE insns where it would put REG_DEAD notes. The last such usage, luckily, disappeared seven years ago with the patch at http://gcc.gnu.org/ml/gcc-patches/2000-10/msg00840.html by Joern Rennecke.

However, for the aforementioned seven years, combine has still been bound-checking every access to its INSN_CUID array. This checking code can actually be replaced with an assertion and bootstrap/regtest still passes. We can thus delete the bounds-checking code as well as the insn_cuid function used if the bounds-checking code failed.

This is not a surprise because combine never does emit_insn_before or emit_insn_after; it has some instances of emit_barrier_after but these would have crashed in insn_cuid if they ever reached it.

This can be a preparatory step towards using LUIDs on dataflow-branch instead of CUIDs. I may try that after the next merge.


2) combine's LOG_LINKS are being reset in the scheduler even though (since the recent patch by Maxim) the scheduler does not even use LOG_LINKS. So I move the resetting of LOG_LINKS back into combine.


This can also be a preparatory step towards removing LOG_LINKS completely!

Bootstrapped/regtested i686-pc-linux-gnu, ok for mainline?

Paolo
2007-02-16  Paolo Bonzini  <bonzini@gnu.org>

	* combine.c (INSN_CUID): Always look up uid_cuid.
	(insn_cuid): Delete.
	(clear_log_links): New.
	(rest_of_handle_combine): Call it.
	* sched-deps.c (sched_analyze): Don't free LOG_LINKS here.
	* sched-int.h (struct dep_list): Don't mention LOG_LINKS in comment.

Index: gcc-test-df/base-gcc-src/gcc/combine.c
===================================================================
--- gcc-test-df/base-gcc-src/gcc/combine.c	(revision 122035)
+++ gcc-test-df/base-gcc-src/gcc/combine.c	(working copy)
@@ -153,7 +153,7 @@ static int max_uid_cuid;
 /* Get the cuid of an insn.  */
 
 #define INSN_CUID(INSN) \
-(INSN_UID (INSN) > max_uid_cuid ? insn_cuid (INSN) : uid_cuid[INSN_UID (INSN)])
+	(uid_cuid[INSN_UID (INSN)])
 
 /* Maximum register number, which is the size of the tables below.  */
 
@@ -443,7 +443,6 @@ static int reg_bitfield_target_p (rtx, r
 static void distribute_notes (rtx, rtx, rtx, rtx, rtx, rtx);
 static void distribute_links (rtx);
 static void mark_used_regs_combine (rtx);
-static int insn_cuid (rtx);
 static void record_promoted_value (rtx, rtx);
 static int unmentioned_reg_p_1 (rtx *, void *);
 static bool unmentioned_reg_p (rtx, rtx);
@@ -11666,28 +11665,15 @@ move_deaths (rtx x, rtx maybe_kill_insn,
     {
       unsigned int regno = REGNO (x);
       rtx where_dead = reg_stat[regno].last_death;
-      rtx before_dead, after_dead;
 
       /* Don't move the register if it gets killed in between from and to.  */
       if (maybe_kill_insn && reg_set_p (x, maybe_kill_insn)
 	  && ! reg_referenced_p (x, maybe_kill_insn))
 	return;
 
-      /* WHERE_DEAD could be a USE insn made by combine, so first we
-	 make sure that we have insns with valid INSN_CUID values.  */
-      before_dead = where_dead;
-      while (before_dead && INSN_UID (before_dead) > max_uid_cuid)
-	before_dead = PREV_INSN (before_dead);
-
-      after_dead = where_dead;
-      while (after_dead && INSN_UID (after_dead) > max_uid_cuid)
-	after_dead = NEXT_INSN (after_dead);
-
-      if (before_dead && after_dead
-	  && INSN_CUID (before_dead) >= from_cuid
-	  && (INSN_CUID (after_dead) < INSN_CUID (to_insn)
-	      || (where_dead != after_dead
-		  && INSN_CUID (after_dead) == INSN_CUID (to_insn))))
+      if (where_dead
+	  && INSN_CUID (where_dead) >= from_cuid
+	  && INSN_CUID (where_dead) < INSN_CUID (to_insn))
 	{
 	  rtx note = remove_death (regno, where_dead);
 
@@ -12284,8 +12270,7 @@ distribute_notes (rtx notes, rtx from_in
 			 i2 but does not die in i2, and place is between i2
 			 and i3, then we may need to move a link from place to
 			 i2.  */
-		      if (i2 && INSN_UID (place) <= max_uid_cuid
-			  && INSN_CUID (place) > INSN_CUID (i2)
+		      if (i2 && INSN_CUID (place) > INSN_CUID (i2)
 			  && from_insn
 			  && INSN_CUID (from_insn) > INSN_CUID (i2)
 			  && reg_referenced_p (XEXP (note, 0), PATTERN (i2)))
@@ -12570,20 +12555,6 @@ unmentioned_reg_p (rtx equiv, rtx expr)
   return for_each_rtx (&equiv, unmentioned_reg_p_1, expr);
 }
 
-/* Compute INSN_CUID for INSN, which is an insn made by combine.  */
-
-static int
-insn_cuid (rtx insn)
-{
-  while (insn != 0 && INSN_UID (insn) > max_uid_cuid
-	 && NONJUMP_INSN_P (insn) && GET_CODE (PATTERN (insn)) == USE)
-    insn = NEXT_INSN (insn);
-
-  gcc_assert (INSN_UID (insn) <= max_uid_cuid);
-
-  return INSN_CUID (insn);
-}
-
 void
 dump_combine_stats (FILE *file)
 {
@@ -12603,6 +12574,19 @@ dump_combine_total_stats (FILE *file)
 }
 
 
+/* Clear LOG_LINKS fields of insns.  */
+
+static void
+clear_log_links (void)
+{
+  rtx insn;
+
+  for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
+    if (INSN_P (insn))
+      free_INSN_LIST_list (&LOG_LINKS (insn));
+}
+
+
 static bool
 gate_handle_combine (void)
 {
@@ -12628,6 +12612,8 @@ rest_of_handle_combine (void)
       delete_dead_jumptables ();
       cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
     }
+  clear_log_links ();
+
   return 0;
 }
 
Index: gcc-test-df/base-gcc-src/gcc/sched-deps.c
===================================================================
--- gcc-test-df/base-gcc-src/gcc/sched-deps.c	(revision 122035)
+++ gcc-test-df/base-gcc-src/gcc/sched-deps.c	(working copy)
@@ -1838,9 +1838,6 @@ sched_analyze (struct deps *deps, rtx he
 
       if (INSN_P (insn))
 	{
-	  /* Clear out the stale LOG_LINKS from flow.  */
-	  free_INSN_LIST_list (&LOG_LINKS (insn));
-
 	  /* These two lists will be freed in schedule_insn ().  */
 	  INSN_BACK_DEPS (insn) = create_deps_list (false);
 	  INSN_RESOLVED_BACK_DEPS (insn) = create_deps_list (false);
Index: gcc-test-df/base-gcc-src/gcc/sched-int.h
===================================================================
--- gcc-test-df/base-gcc-src/gcc/sched-int.h	(revision 122035)
+++ gcc-test-df/base-gcc-src/gcc/sched-int.h	(working copy)
@@ -112,8 +112,7 @@ typedef struct _dep_link *dep_link_t;
 
 void debug_dep_links (dep_link_t);
 
-/* A list of dep_links.  Lists of this type are now used instead of rtx
-   LOG_LINKS and alike lists.  */
+/* A list of dep_links.  */
 struct _deps_list
 {
   dep_link_t first;

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