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]

[tree-ssa][PATCH]: Fix PR/13163


Whee.

Bootstrapped and regtested on i686-pc-linux-gnu (also bootstrapped
powerpc-apple-darwin).

2003-11-23  Daniel Berlin  <dberlin@dberlin.org>

	Fix PR/13163
	* tree-ssa-pre.c (append_eref_to_block): Delete.
	(insert_euse_in_preorder_dt_order_1): Ditto.
	(insert_one_operand): Take an extra argument, because
	avdefs may need to be changed.
	(clear_all_eref_arrays): Use FOR_ALL_BB.
	(insert_occ_in_preorder_dt_order): Stop appending to bb eref arrays.
	Use FOR_ALL_BB.
	(insert_euse_in_preorder_dt_order): Rewrite to just build a new varray
	with only the EPHI's and EUSE's, and then sort it.
	(pre_expression): Don't use bb based erefs array when printing
	expressions.
	(split_critical_edges): Just use FOR_ALL_BB.
	(tree_perform_ssapre): Pre-split entry block successor edge if the
	successor block has multiple preds.

	* tree-flow.h (struct bb_ann_d): Remove erefs varray.

Index: tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-pre.c,v
retrieving revision 1.1.4.109
diff -u -3 -p -r1.1.4.109 tree-ssa-pre.c
--- tree-ssa-pre.c	22 Nov 2003 05:46:46 -0000	1.1.4.109
+++ tree-ssa-pre.c	24 Nov 2003 19:40:06 -0000
@@ -113,7 +113,6 @@
 static int dump_flags;

 struct expr_info;
-static inline void append_eref_to_block (tree, basic_block);
 static void clear_all_eref_arrays (void);
 static inline bool expr_lexically_eq (const tree, const tree);
 static void free_expr_info (struct expr_info *);
@@ -138,8 +137,6 @@
 static void process_delayed_rename (struct expr_info *, tree, tree);
 static void assign_new_class (tree, varray_type *, varray_type *);
 static void insert_occ_in_preorder_dt_order (struct expr_info *);
-static void insert_euse_in_preorder_dt_order_1 (struct expr_info *,
-						basic_block);
 static void insert_euse_in_preorder_dt_order (struct expr_info *);
 static bool ephi_has_unsafe_arg (tree);
 static void reset_down_safe (tree, int);
@@ -243,7 +240,8 @@
 					      tree, basic_block, int);
 static void compute_du_info (struct expr_info *);
 static void add_ephi_use (tree, tree, int);
-static void insert_one_operand (struct expr_info *, tree, int, tree, edge);
+static void insert_one_operand (struct expr_info *, tree, int, tree, edge,
+				tree **);
 static bool split_critical_edges (void);
 static void collect_expressions (basic_block, varray_type *);
 static int build_dfn_array (basic_block, int);
@@ -748,16 +746,6 @@
     }
 }

-/* Append REF to the array of expression references for BB.  */
-
-static inline void
-append_eref_to_block (tree ref, basic_block bb)
-{
-  bb_ann_t ann = bb_ann (bb);
-  if (ann->erefs == NULL)
-    VARRAY_GENERIC_PTR_NOGC_INIT (ann->erefs, 1, "Expression references");
-  VARRAY_PUSH_TREE (ann->erefs, ref);
-}

 /* Clear all the expression reference arrays.  */

@@ -767,12 +755,9 @@
   basic_block bb;
   bb_ann_t ann;

-  FOR_EACH_BB (bb)
+  FOR_ALL_BB (bb)
     {
       ann = bb_ann (bb);
-      if (ann->erefs)
-	VARRAY_FREE (ann->erefs);
-      ann->erefs = NULL;
       if (ann->ephi_nodes)
 	{
 	  free (ann->ephi_nodes);
@@ -1028,7 +1013,6 @@
 	    tree killexpr  = VARRAY_TREE (ei->kills, i);
 	    tree killname = ei->expr;
 	    newref = create_expr_ref (ei, killname, EKILL_NODE, block, killexpr);
-	    append_eref_to_block (newref, block);
 	    VARRAY_PUSH_TREE (ei->euses_dt_order, newref);
 	  }
 	else if (VARRAY_TREE (ei->lefts, i) != NULL)
@@ -1038,7 +1022,6 @@
 	    occurname = ei->expr;
 	    newref = create_expr_ref (ei, occurname, EUSE_NODE, block,
 				      occurexpr);
-	    append_eref_to_block (newref, block);
 	    EUSE_DEF (newref) = NULL_TREE;
 	    EUSE_LVAL (newref) = true;
 	    EREF_CLASS (newref) = -1;
@@ -1053,7 +1036,6 @@
 	    occurname = ei->expr;
 	    newref = create_expr_ref (ei, occurname, EUSE_NODE, block,
 				      occurexpr);
-	    append_eref_to_block (newref, block);
 	    EUSE_DEF (newref) = NULL_TREE;
 	    EREF_CLASS (newref) = -1;
 	    EUSE_PHIOP (newref) = false;
@@ -1063,7 +1045,7 @@
       }


-  FOR_EACH_BB (block)
+  FOR_ALL_BB (block)
   {
     /* Insert the phi operand occurrences's in the heap at the
        successors.*/
@@ -1078,7 +1060,6 @@
 		tree newref = create_expr_ref (ei, 0, EUSE_NODE, block, NULL);
 		curr_phi_pred = newref;
 		VARRAY_PUSH_TREE (ei->euses_dt_order, newref);
-		append_eref_to_block (newref, block);
 		EUSE_DEF (newref) = NULL_TREE;
 		EREF_CLASS (newref) = -1;
 		EUSE_PHIOP (newref) = true;
@@ -1106,7 +1087,6 @@
 	    newref = create_expr_ref (ei, ei->expr, EEXIT_NODE,
 				      block,
 				      NULL);
-	    append_eref_to_block (newref, block);
 	    VARRAY_PUSH_TREE (ei->euses_dt_order, newref);
 	  }
       }
@@ -1873,49 +1853,28 @@
   compute_stops (ei);
 }

-/* Insert the expressions in preorder DT order into ei->euses_dt_order.  */
+/* Insert the expressions into ei->euses_dt_order in preorder dt order.  */

 static void
-insert_euse_in_preorder_dt_order_1 (struct expr_info *ei, basic_block block)
+insert_euse_in_preorder_dt_order (struct expr_info *ei)
 {
-  bb_ann_t ann = bb_ann (block);
+  varray_type new_euses_dt_order;
   size_t i;
+  VARRAY_GENERIC_PTR_NOGC_INIT (new_euses_dt_order, 1, "EUSEs");

-  if (ephi_at_block (block) != NULL_TREE)
-      VARRAY_PUSH_TREE (ei->euses_dt_order, ephi_at_block (block));
-
-  if (ann->erefs)
+  for (i = 0; i < VARRAY_ACTIVE_SIZE (ei->euses_dt_order); i++)
     {
-      for (i = 0; i < VARRAY_ACTIVE_SIZE (ann->erefs); i++)
-	{
-	  tree ref = VARRAY_TREE (ann->erefs, i);
-	  if (!ref)
-	    continue;
-
-	  if (TREE_CODE (ref) == EUSE_NODE)
-	    VARRAY_PUSH_TREE (ei->euses_dt_order, ref);
-#ifdef ENABLE_CHECKING
-	  else if (TREE_CODE (ref) == EPHI_NODE)
-	    abort ();
-#endif
-
-	}
+      tree ref = VARRAY_TREE (ei->euses_dt_order, i);
+      if (TREE_CODE (ref) == EUSE_NODE || TREE_CODE (ref) == EPHI_NODE)
+	VARRAY_PUSH_TREE (new_euses_dt_order, ref);
     }
+  VARRAY_FREE (ei->euses_dt_order);
+  ei->euses_dt_order = new_euses_dt_order;
+  qsort (ei->euses_dt_order->data.tree,
+	 VARRAY_ACTIVE_SIZE (ei->euses_dt_order),
+	 sizeof (tree),
+	 eref_compare);

-  if (dom_children (block))
-    EXECUTE_IF_SET_IN_BITMAP (dom_children (block), 0, i,
-    {
-      insert_euse_in_preorder_dt_order_1 (ei, BASIC_BLOCK (i));
-    });
-}
-
-/* Insert the expressions into ei->euses_dt_order in preorder dt order.  */
-
-static void
-insert_euse_in_preorder_dt_order (struct expr_info *ei)
-{
-  VARRAY_CLEAR (ei->euses_dt_order);
-  insert_euse_in_preorder_dt_order_1 (ei, ENTRY_BLOCK_PTR->next_bb);
 }

 /* Determine if we can insert operand OPND_INDX of EPHI.  */
@@ -2045,7 +2004,7 @@

 static void
 insert_one_operand (struct expr_info *ei, tree ephi, int opnd_indx,
-		    tree x, edge succ)
+		    tree x, edge succ, tree **avdefsp)
 {
   tree expr;
   tree temp = ei->temp;
@@ -2084,7 +2043,11 @@
   EPHI_ARG_DEF (ephi, opnd_indx)
     = create_expr_ref (ei, ei->expr, EUSE_NODE, bb, 0);
   EUSE_DEF (x) = EPHI_ARG_DEF (ephi, opnd_indx);
-  append_eref_to_block (EPHI_ARG_DEF (ephi, opnd_indx), bb);
+  VARRAY_PUSH_TREE (ei->euses_dt_order, EPHI_ARG_DEF (ephi, opnd_indx));
+  qsort (ei->euses_dt_order->data.tree,
+	 VARRAY_ACTIVE_SIZE (ei->euses_dt_order),
+	 sizeof (tree),
+	 eref_compare);
   EREF_TEMP (EUSE_DEF (x)) = newtemp;
   EREF_RELOAD (EUSE_DEF (x)) = false;
   EREF_SAVE (EUSE_DEF (x)) = false;
@@ -2095,6 +2058,9 @@
   EUSE_INSERTED (x) = true;
   EREF_CLASS (x) = class_count++;
   EREF_CLASS (EUSE_DEF (x)) = class_count++;
+  *avdefsp = xrealloc (*avdefsp, sizeof (tree) * (class_count + 1));
+  (*avdefsp)[class_count - 2] = x;
+  (*avdefsp)[class_count - 1] = EUSE_DEF (x);
   pre_stats.saves++;
 }

@@ -2166,7 +2132,8 @@
 #endif
 		  if (can_insert (ephi, opnd_indx))
 		    {
-		      insert_one_operand (ei, ephi, opnd_indx, x, succ);
+		      insert_one_operand (ei, ephi, opnd_indx, x, succ,
+					  &avdefs);
 		    }
 		  else
 		    {
@@ -2481,7 +2448,6 @@
 	  set_save (ei, EUSE_DEF (ref));
 	}
     }
-
   /* ESSA Minimization.  */
   for (i = 0; i < VARRAY_ACTIVE_SIZE (ei->euses_dt_order); i++)
     {
@@ -3046,21 +3012,15 @@
   rename_1 (ei);
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
-      basic_block bb;
-      bb_ann_t ann;
       size_t i;
       fprintf (dump_file, "Occurrences for expression ");
       print_generic_expr (dump_file, ei->expr, 0);
       fprintf (dump_file, " after Rename 2\n");
-      FOR_EACH_BB (bb)
+      for (i = 0; i < VARRAY_ACTIVE_SIZE (ei->euses_dt_order); i++)
 	{
-	  ann = bb_ann (bb);
-	  if (ann->erefs)
-	    for (i = 0; i < VARRAY_ACTIVE_SIZE (ann->erefs); i++)
-	      {
-		print_generic_expr (dump_file, VARRAY_TREE (ann->erefs, i), 1);
-		fprintf (dump_file, "\n");
-	      }
+	  print_generic_expr (dump_file,
+			      VARRAY_TREE (ei->euses_dt_order, i), 1);
+	  fprintf (dump_file, "\n");
 	}
     }
   compute_down_safety (ei);
@@ -3127,7 +3087,7 @@
   basic_block bb;
   edge e;

-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+  FOR_ALL_BB (bb)
     {
       for (e = bb->succ; e ; e = e->succ_next)
 	if (EDGE_CRITICAL_P (e) && !(e->flags & EDGE_ABNORMAL))
@@ -3256,9 +3216,12 @@
   size_t k;
   int i;
   sbitmap vars_to_rename;
-
-
+
   split_critical_edges ();
+
+  if (ENTRY_BLOCK_PTR->succ->dest->pred->pred_next)
+    tree_split_edge (ENTRY_BLOCK_PTR->succ);
+
   timevar_push (TV_TREE_PRE);
   dump_file = dump_begin (phase, &dump_flags);
   euse_node_pool = create_alloc_pool ("EUSE node pool",
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.158
--- tree-flow.h	20 Nov 2003 20:54:39 -0000	1.1.4.158
+++ tree-flow.h	24 Nov 2003 19:40:06 -0000
@@ -311,9 +311,6 @@
   /* Chain of EPHI nodes created in this block.  */
   tree ephi_nodes;

-  /* EUSE/ELEFT/EKILL/EPHI nodes created in this block.  */
-  varray_type erefs;
-
   /* Number of predecessors for this block.  This is only valid during
      SSA rewriting.  It is not maintained after conversion into SSA form.  */
   int num_preds;


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