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]

Re: 1.1.2 gcse bug


> On Mon, May 10, 1999 at 03:47:00AM -0700, Richard Henderson wrote:
> > 	* gcse.c (compute_pre_ppinout): Zero initial ppout for all
> > 	exit blocks.

I hadn't noticed that the forward prop pass wasn't pushing the bits
forward into the exit block (n_basic_blocks-1).  Following this
strategy for all of the dead-end blocks solves the convergance problem.

I've checked this in to the 1.1 branch.


r~


        * gcse.c (compute_pre_ppinout): Zero initial ppout for all
        exit blocks, and don't forward propogate into them either.

	* flow.c (add_pred_succ): Don't add duplicate edges.

Index: gcse.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/gcse.c,v
retrieving revision 1.10.2.2
diff -u -p -d -r1.10.2.2 gcse.c
--- gcse.c	1998/10/02 00:26:21	1.10.2.2
+++ gcse.c	1999/05/13 20:01:35
@@ -4146,12 +4146,18 @@ compute_pre_ppinout ()
   int bb, i, changed, size, passes;
 
   sbitmap_vector_ones (pre_ppin, n_basic_blocks);
-  /* ??? Inefficient as we set pre_ppin[0] twice, but simple.  */
   sbitmap_zero (pre_ppin[0]);
 
+  /* Placement Possible out is initially set on all except exit blocks.
+     That is, either blocks whose sole successor is exit, or who have no
+     successors at all, such as would be created by a function that does
+     not return.  */
   sbitmap_vector_ones (pre_ppout, n_basic_blocks);
-  /* ??? Inefficient as we set pre_ppout[n_basic_blocks-1] twice, but simple.  */
-  sbitmap_zero (pre_ppout[n_basic_blocks - 1]);
+  for (bb = 0; bb < n_basic_blocks; bb++)
+    if (s_succs[bb] == NULL
+	|| (s_succs[bb]->next == NULL
+	    && s_succs[bb]->val == EXIT_BLOCK))
+      sbitmap_zero (pre_ppout[bb]);
 
   size = pre_ppin[0]->size;
   passes = 0;
@@ -4171,8 +4177,9 @@ compute_pre_ppinout ()
 	  for (i = 0; i < size; i++)
 	    {
 	      int_list_ptr pred;
-	      SBITMAP_ELT_TYPE tmp = *antin & *pavin & (*antloc | (*transp & *ppout));
-	      SBITMAP_ELT_TYPE pred_val = -1L;
+	      SBITMAP_ELT_TYPE tmp, pred_val = -1L;
+
+	      tmp = *antin & *pavin & (*antloc | (*transp & *ppout));
 
 	      for (pred = s_preds[bb]; pred != NULL; pred = pred->next)
 		{
@@ -4206,13 +4213,18 @@ compute_pre_ppinout ()
 	    }
 	}
 
-      for (bb = 0; bb < n_basic_blocks - 1; bb++)
+      for (bb = 0; bb < n_basic_blocks; bb++)
 	{
 	  sbitmap_ptr ppout = pre_ppout[bb]->elms;
 
-	  for (i = 0; i < size; i++)
+	  if (s_succs[bb] == NULL
+	      || (s_succs[bb]->next == NULL
+		  && s_succs[bb]->val == EXIT_BLOCK))
+	    continue;
+
+	  for (i = 0; i < size; i++, ppout++)
 	    {
-	      int_list_ptr succ;
+	      int_list_ptr succ = s_succs[bb];
 	      SBITMAP_ELT_TYPE tmp = -1L;
 
 	      for (succ = s_succs[bb]; succ != NULL; succ = succ->next)
@@ -4229,10 +4241,8 @@ compute_pre_ppinout ()
 	      if (*ppout != tmp)
 		{
 		  changed = 1;
-		  *ppout++ = tmp;
+		  *ppout = tmp;
 		}
-	      else
-		ppout++;
 	    }
 	}
 
Index: flow.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/flow.c,v
retrieving revision 1.55
diff -u -p -d -r1.55 flow.c
--- flow.c	1998/07/08 21:15:55	1.55
+++ flow.c	1999/05/13 20:01:41
@@ -3282,15 +3282,28 @@ add_pred_succ (pred_bb, succ_bb, s_preds
      int *num_preds;
      int *num_succs;
 {
+  int_list_ptr tmp;
   if (succ_bb != EXIT_BLOCK)
     {
-      add_int_list_node (&pred_int_list_blocks, &s_preds[succ_bb], pred_bb);
-      num_preds[succ_bb]++;
+      for (tmp = s_preds[succ_bb]; tmp; tmp = tmp->next)
+	if (tmp->val == pred_bb)
+	  break;
+      if (tmp == NULL)
+	{
+	  add_int_list_node (&pred_int_list_blocks, &s_preds[succ_bb], pred_bb);
+	  num_preds[succ_bb]++;
+	}
     }
   if (pred_bb != ENTRY_BLOCK)
     {
-      add_int_list_node (&pred_int_list_blocks, &s_succs[pred_bb], succ_bb);
-      num_succs[pred_bb]++;
+      for (tmp = s_succs[pred_bb]; tmp; tmp = tmp->next)
+	if (tmp->val == succ_bb)
+	  break;
+      if (tmp == NULL)
+	{
+	  add_int_list_node (&pred_int_list_blocks, &s_succs[pred_bb], succ_bb);
+	  num_succs[pred_bb]++;
+	}
     }
 }
 


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