]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
basic-block.h (basic_block_def): Add phi_nodes and predictions.
authorKazu Hirata <kazu@cs.umass.edu>
Fri, 27 May 2005 22:06:46 +0000 (22:06 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Fri, 27 May 2005 22:06:46 +0000 (22:06 +0000)
* basic-block.h (basic_block_def): Add phi_nodes and
predictions.  Remove tree_annotations.
* predict.c (tree_predicted_by_p, tree_predict_edge,
combine_predictions_for_bb): Adjust references to predictions.
* tree-cfg.c (init_empty_tree_cfg, create_bb): Don't call
create_block_annotation.
(create_block_annotation, free_blocks_annotatios,
clear_blocks_annotations): Remove.
(dump_cfg_stats): Don't print out the memory spent on
bb_ann_d.
(delete_tree_cfg_annotations): Don't call free_blocks_annotations.
* tree-flow-inline.h (bb_ann): Remove.
(phi_nodes, set_phi_nodes): Update references to phi_nodes.
* tree-flow.h (bb_ann_d): Remove.
* tree-if-conv.c (process_phi_nodes): Update a reference to
phi_nodes.
* tree-phinodes.c (reserve_phi_args_for_new_edge,
create_phi_node, remove_phi_node): Likewise.
* tree-pretty-print.c (dump_generic_bb_buff): Don't call bb_ann.
* tree-ssa-dom.c (threaded_blocks): New.
(tree_ssa_dominator_optimize): Initialize, clear, and free
threaded_blocks. Update a call to thread_through_all_blocks.
(thread_across_edge): Use threaded_blocks instead of setting
incoming_edge_threaded.
* tree-ssa-threadupdate.c (threaded_through_all_blocks): Take
a bitmap of blocks that are threaded through.
* tree.h: Move the prototype of threaded_through_blocks to
tree-flow.h.

From-SVN: r100279

12 files changed:
gcc/ChangeLog
gcc/basic-block.h
gcc/predict.c
gcc/tree-cfg.c
gcc/tree-flow-inline.h
gcc/tree-flow.h
gcc/tree-if-conv.c
gcc/tree-phinodes.c
gcc/tree-pretty-print.c
gcc/tree-ssa-dom.c
gcc/tree-ssa-threadupdate.c
gcc/tree.h

index 5f06858a85cb1ea5755b32a4676c9da359fcdcac..f9753e92c7a260acb88220504d88970dfbf5edd1 100644 (file)
@@ -1,3 +1,34 @@
+2005-05-27  Kazu Hirata  <kazu@cs.umass.edu>
+
+       * basic-block.h (basic_block_def): Add phi_nodes and
+       predictions.  Remove tree_annotations.
+       * predict.c (tree_predicted_by_p, tree_predict_edge,
+       combine_predictions_for_bb): Adjust references to predictions.
+       * tree-cfg.c (init_empty_tree_cfg, create_bb): Don't call
+       create_block_annotation.
+       (create_block_annotation, free_blocks_annotatios,
+       clear_blocks_annotations): Remove.
+       (dump_cfg_stats): Don't print out the memory spent on
+       bb_ann_d.
+       (delete_tree_cfg_annotations): Don't call free_blocks_annotations.
+       * tree-flow-inline.h (bb_ann): Remove.
+       (phi_nodes, set_phi_nodes): Update references to phi_nodes.
+       * tree-flow.h (bb_ann_d): Remove.
+       * tree-if-conv.c (process_phi_nodes): Update a reference to
+       phi_nodes.
+       * tree-phinodes.c (reserve_phi_args_for_new_edge,
+       create_phi_node, remove_phi_node): Likewise.
+       * tree-pretty-print.c (dump_generic_bb_buff): Don't call bb_ann.
+       * tree-ssa-dom.c (threaded_blocks): New.
+       (tree_ssa_dominator_optimize): Initialize, clear, and free
+       threaded_blocks. Update a call to thread_through_all_blocks.
+       (thread_across_edge): Use threaded_blocks instead of setting
+       incoming_edge_threaded.
+       * tree-ssa-threadupdate.c (threaded_through_all_blocks): Take
+       a bitmap of blocks that are threaded through.
+       * tree.h: Move the prototype of threaded_through_blocks to
+       tree-flow.h.
+
 2005-05-27  Jan Hubicka  <jh@suse.cz>
 
        * cgraph.c: Include tree-gimple.h
index 4deeb8997550f8029bc7507ca1e43a8ff0df4a38..cedeac5ff50c37f43b9d0daecaf3c0b753ea71da 100644 (file)
@@ -185,6 +185,9 @@ struct loops;
 /* Declared in tree-flow.h.  */
 struct bb_ann_d;
 
+/* Declared in tree-flow.h.  */
+struct edge_prediction;
+
 /* A basic block is a sequence of instructions with only entry and
    only one exit.  If any one of the instructions are executed, they
    will all be executed, and in sequence from first to last.
@@ -246,8 +249,11 @@ struct basic_block_def GTY((chain_next ("%h.next_bb"), chain_prev ("%h.prev_bb")
   /* The data used by basic block copying and reordering functions.  */
   struct reorder_block_def * rbi;
 
-  /* Annotations used at the tree level.  */
-  struct bb_ann_d *tree_annotations;
+  /* Chain of PHI nodes for this block.  */
+  tree phi_nodes;
+
+  /* A list of predictions.  */
+  struct edge_prediction *predictions;
 
   /* Expected number of executions: calculated in profile.c.  */
   gcov_type count;
index 961a39526a15c3f6ec185c011240597892c73156..25f97f707a669e55f7e3bc555dd3850cfc4a2ff2 100644 (file)
@@ -171,8 +171,8 @@ rtl_predicted_by_p (basic_block bb, enum br_predictor predictor)
 bool
 tree_predicted_by_p (basic_block bb, enum br_predictor predictor)
 {
-  struct edge_prediction *i = bb_ann (bb)->predictions;
-  for (i = bb_ann (bb)->predictions; i; i = i->next)
+  struct edge_prediction *i;
+  for (i = bb->predictions; i; i = i->next)
     if (i->predictor == predictor)
       return true;
   return false;
@@ -233,8 +233,8 @@ tree_predict_edge (edge e, enum br_predictor predictor, int probability)
 {
   struct edge_prediction *i = ggc_alloc (sizeof (struct edge_prediction));
 
-  i->next = bb_ann (e->src)->predictions;
-  bb_ann (e->src)->predictions = i;
+  i->next = e->src->predictions;
+  e->src->predictions = i;
   i->probability = probability;
   i->predictor = predictor;
   i->edge = e;
@@ -488,7 +488,7 @@ combine_predictions_for_bb (FILE *file, basic_block bb)
     {
       if (!bb->count)
        set_even_probabilities (bb);
-      bb_ann (bb)->predictions = NULL;
+      bb->predictions = NULL;
       if (file)
        fprintf (file, "%i edges in bb %i predicted to even probabilities\n",
                 nedges, bb->index);
@@ -500,7 +500,7 @@ combine_predictions_for_bb (FILE *file, basic_block bb)
 
   /* We implement "first match" heuristics and use probability guessed
      by predictor with smallest index.  */
-  for (pred = bb_ann (bb)->predictions; pred; pred = pred->next)
+  for (pred = bb->predictions; pred; pred = pred->next)
     {
       int predictor = pred->predictor;
       int probability = pred->probability;
@@ -546,7 +546,7 @@ combine_predictions_for_bb (FILE *file, basic_block bb)
     combined_probability = best_probability;
   dump_prediction (file, PRED_COMBINED, combined_probability, bb, true);
 
-  for (pred = bb_ann (bb)->predictions; pred; pred = pred->next)
+  for (pred = bb->predictions; pred; pred = pred->next)
     {
       int predictor = pred->predictor;
       int probability = pred->probability;
@@ -556,7 +556,7 @@ combine_predictions_for_bb (FILE *file, basic_block bb)
       dump_prediction (file, predictor, probability, bb,
                       !first_match || best_predictor == predictor);
     }
-  bb_ann (bb)->predictions = NULL;
+  bb->predictions = NULL;
 
   if (!bb->count)
     {
index a219d8b760f097e3d0a4df55c983a9652d4dc003..f0428b3693862b61ef3de3363579afc12a0cf536 100644 (file)
@@ -95,9 +95,6 @@ static bool found_computed_goto;
 
 /* Basic blocks and flowgraphs.  */
 static basic_block create_bb (void *, void *, basic_block);
-static void create_block_annotation (basic_block);
-static void free_blocks_annotations (void);
-static void clear_blocks_annotations (void);
 static void make_blocks (tree);
 static void factor_computed_gotos (void);
 
@@ -149,9 +146,6 @@ init_empty_tree_cfg (void)
 
   ENTRY_BLOCK_PTR->next_bb = EXIT_BLOCK_PTR;
   EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR;
-
-  create_block_annotation (ENTRY_BLOCK_PTR);
-  create_block_annotation (EXIT_BLOCK_PTR);
 }
 
 /*---------------------------------------------------------------------------
@@ -322,37 +316,6 @@ factor_computed_gotos (void)
 }
 
 
-/* Create annotations for a single basic block.  */
-
-static void
-create_block_annotation (basic_block bb)
-{
-  /* Verify that the tree_annotations field is clear.  */
-  gcc_assert (!bb->tree_annotations);
-  bb->tree_annotations = ggc_alloc_cleared (sizeof (struct bb_ann_d));
-}
-
-
-/* Free the annotations for all the basic blocks.  */
-
-static void free_blocks_annotations (void)
-{
-  clear_blocks_annotations ();  
-}
-
-
-/* Clear the annotations for all the basic blocks.  */
-
-static void
-clear_blocks_annotations (void)
-{
-  basic_block bb;
-
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
-    bb->tree_annotations = NULL;
-}
-
-
 /* Build a flowgraph for the statement_list STMT_LIST.  */
 
 static void
@@ -431,8 +394,6 @@ create_bb (void *h, void *e, basic_block after)
   /* Add the newly created block to the array.  */
   BASIC_BLOCK (last_basic_block) = bb;
 
-  create_block_annotation (bb);
-
   n_basic_blocks++;
   last_basic_block++;
 
@@ -2561,11 +2522,6 @@ dump_cfg_stats (FILE *file)
   total += size;
   fprintf (file, fmt_str_1, "Edges", num_edges, SCALE (size), LABEL (size));
 
-  size = n_basic_blocks * sizeof (struct bb_ann_d);
-  total += size;
-  fprintf (file, fmt_str_1, "Basic block annotations", n_basic_blocks,
-          SCALE (size), LABEL (size));
-
   fprintf (file, "---------------------------------------------------------\n");
   fprintf (file, fmt_str_3, "Total memory used by CFG data", SCALE (total),
           LABEL (total));
@@ -2876,8 +2832,6 @@ void
 delete_tree_cfg_annotations (void)
 {
   basic_block bb;
-  if (n_basic_blocks > 0)
-    free_blocks_annotations ();
 
   label_to_block_map = NULL;
   FOR_EACH_BB (bb)
index 31afd9d0893ae580e62c0ec668a261b9199a9d17..d7b0aa45b50480c1a21e8d47603ccc6da5b70fec 100644 (file)
@@ -494,19 +494,12 @@ addresses_taken (tree stmt)
   return ann ? ann->addresses_taken : NULL;
 }
 
-/* Return the basic_block annotation for BB.  */
-static inline bb_ann_t
-bb_ann (basic_block bb)
-{
-  return (bb_ann_t)bb->tree_annotations;
-}
-
 /* Return the PHI nodes for basic block BB, or NULL if there are no
    PHI nodes.  */
 static inline tree
 phi_nodes (basic_block bb)
 {
-  return bb_ann (bb)->phi_nodes;
+  return bb->phi_nodes;
 }
 
 /* Set list of phi nodes of a basic block BB to L.  */
@@ -516,7 +509,7 @@ set_phi_nodes (basic_block bb, tree l)
 {
   tree phi;
 
-  bb_ann (bb)->phi_nodes = l;
+  bb->phi_nodes = l;
   for (phi = l; phi; phi = PHI_CHAIN (phi))
     set_bb_for_stmt (phi, bb);
 }
index 974e8b0ca87542b08e3090456f4c6b2be5e042f6..ceb2b336b9be71dee39faf7bef227d433fbbc0df 100644 (file)
@@ -377,25 +377,7 @@ struct edge_prediction GTY((chain_next ("%h.next")))
   int probability;
 };
 
-/*---------------------------------------------------------------------------
-                 Block annotations stored in basic_block.tree_annotations
----------------------------------------------------------------------------*/
-struct bb_ann_d GTY(())
-{
-  /* Chain of PHI nodes for this block.  */
-  tree phi_nodes;
-
-  /* Nonzero if one or more incoming edges to this block should be threaded
-     to an outgoing edge of this block.  */
-  unsigned incoming_edge_threaded : 1;
-
-  struct edge_prediction *predictions;
-};
-
-typedef struct bb_ann_d *bb_ann_t;
-
 /* Accessors for basic block annotations.  */
-static inline bb_ann_t bb_ann (basic_block);
 static inline tree phi_nodes (basic_block);
 static inline void set_phi_nodes (basic_block, tree);
 
@@ -782,6 +764,9 @@ extern void linear_transform_loops (struct loops *);
 /* In tree-ssa-loop-ivopts.c  */
 extern bool expr_invariant_in_loop_p (struct loop *, tree);
 
+/* In tree-ssa-threadupdate.c.  */
+extern bool thread_through_all_blocks (bitmap);
+
 /* In gimplify.c  */
 tree force_gimple_operand (tree, tree *, bool, tree);
 tree force_gimple_operand_bsi (block_stmt_iterator *, tree, bool, tree);
index decd9cde6afec22666fe220b2586d1f84c43af3c..82a710af9d5363b238844361b8b4f3921c3425b6 100644 (file)
@@ -840,7 +840,7 @@ process_phi_nodes (struct loop *loop)
          release_phi_node (phi);
          phi = next;
        }
-      bb_ann (bb)->phi_nodes = NULL;
+      bb->phi_nodes = NULL;
     }
   return;
 }
index ca01c8c52d1b43a3d60a7bc8dc75cb6d19d284b2..7faedc907bedc260b5aebd84518b90038b498d72 100644 (file)
@@ -314,7 +314,7 @@ reserve_phi_args_for_new_edge (basic_block bb)
   int len = EDGE_COUNT (bb->preds);
   int cap = ideal_phi_node_len (len + 4);
 
-  for (loc = &(bb_ann (bb)->phi_nodes);
+  for (loc = &(bb->phi_nodes);
        *loc;
        loc = &PHI_CHAIN (*loc))
     {
@@ -354,7 +354,7 @@ create_phi_node (tree var, basic_block bb)
 
   /* Add the new PHI node to the list of PHI nodes for block BB.  */
   PHI_CHAIN (phi) = phi_nodes (bb);
-  bb_ann (bb)->phi_nodes = phi;
+  bb->phi_nodes = phi;
 
   /* Associate BB to the PHI node.  */
   set_bb_for_stmt (phi, bb);
@@ -450,7 +450,7 @@ remove_phi_node (tree phi, tree prev)
     }
   else
     {
-      for (loc = &(bb_ann (bb_for_stmt (phi))->phi_nodes);
+      for (loc = &(bb_for_stmt (phi)->phi_nodes);
           *loc != phi;
           loc = &PHI_CHAIN (*loc))
        ;
index 52bf437ff9869c091ff0629dd73f49904b777301..6ac56dd76e764f113b93c21bdfb698b82419008b 100644 (file)
@@ -2341,8 +2341,7 @@ dump_generic_bb_buff (pretty_printer *buffer, basic_block bb,
 
   dump_bb_header (buffer, bb, indent, flags);
 
-  if (bb_ann (bb))
-    dump_phi_nodes (buffer, bb, indent, flags);
+  dump_phi_nodes (buffer, bb, indent, flags);
 
   for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
     {
index cb4abcf35d32b3d52caf043206b733a18f2d7747..910ddce5a70f9297678b46a500ca4310049a9b10 100644 (file)
@@ -141,6 +141,10 @@ static VEC(tree,heap) *const_and_copies_stack;
    know their exact value.  */
 static bitmap nonzero_vars;
 
+/* Bitmap of blocks that are scheduled to be threaded through.  This
+   is used to communicate with thread_through_blocks.  */
+static bitmap threaded_blocks;
+
 /* Stack of SSA_NAMEs which need their NONZERO_VARS property cleared
    when the current block is finalized. 
 
@@ -370,6 +374,7 @@ tree_ssa_dominator_optimize (void)
   vrp_variables_stack = VEC_alloc (tree, heap, 20);
   stmts_to_rescan = VEC_alloc (tree, heap, 20);
   nonzero_vars = BITMAP_ALLOC (NULL);
+  threaded_blocks = BITMAP_ALLOC (NULL);
   need_eh_cleanup = BITMAP_ALLOC (NULL);
 
   /* Setup callbacks for the generic dominator tree walker.  */
@@ -445,7 +450,7 @@ tree_ssa_dominator_optimize (void)
       free_all_edge_infos ();
 
       /* Thread jumps, creating duplicate blocks as needed.  */
-      cfg_altered |= thread_through_all_blocks ();
+      cfg_altered |= thread_through_all_blocks (threaded_blocks);
 
       /* Removal of statements may make some EH edges dead.  Purge
         such edges from the CFG as needed.  */
@@ -480,6 +485,7 @@ tree_ssa_dominator_optimize (void)
 
       /* Reinitialize the various tables.  */
       bitmap_clear (nonzero_vars);
+      bitmap_clear (threaded_blocks);
       htab_empty (avail_exprs);
       htab_empty (vrp_data);
 
@@ -523,6 +529,7 @@ tree_ssa_dominator_optimize (void)
 
   /* Free nonzero_vars.  */
   BITMAP_FREE (nonzero_vars);
+  BITMAP_FREE (threaded_blocks);
   BITMAP_FREE (need_eh_cleanup);
   
   VEC_free (tree, heap, avail_exprs_stack);
@@ -830,7 +837,7 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
              else
                edge_info = allocate_edge_info (e);
              edge_info->redirection_target = taken_edge;
-             bb_ann (e->dest)->incoming_edge_threaded = true;
+             bitmap_set_bit (threaded_blocks, e->dest->index);
            }
        }
     }
index e72598d830ee1222c7b6e96ebdcde6abaf43639f..f6bf1db7324ca37740140e9953a64ebaa5261b19 100644 (file)
@@ -802,22 +802,20 @@ thread_block (basic_block bb)
    Returns true if one or more edges were threaded, false otherwise.  */
 
 bool
-thread_through_all_blocks (void)
+thread_through_all_blocks (bitmap threaded_blocks)
 {
-  basic_block bb;
   bool retval = false;
+  unsigned int i;
+  bitmap_iterator bi;
 
   rediscover_loops_after_threading = false;
 
-  FOR_EACH_BB (bb)
+  EXECUTE_IF_SET_IN_BITMAP (threaded_blocks, 0, i, bi)
     {
-      if (bb_ann (bb)->incoming_edge_threaded
-         && EDGE_COUNT (bb->preds) > 0)
-       {
-         retval |= thread_block (bb);
-         bb_ann (bb)->incoming_edge_threaded = false;
-         
-       }
+      basic_block bb = BASIC_BLOCK (i);
+
+      if (EDGE_COUNT (bb->preds) > 0)
+       retval |= thread_block (bb);
     }
 
   return retval;
index b7764d81882641a0c9a97ac3fe35cb1356526fa0..e72a20fddca71b9551e5211649bbe7b3938b9591 100644 (file)
@@ -3975,9 +3975,6 @@ extern int tree_node_sizes[];
    restricted to creating gimple expressions.  */
 extern bool in_gimple_form;
 
-/* In tree-ssa-threadupdate.c.  */
-extern bool thread_through_all_blocks (void);
-
 /* In tree-gimple.c.  */
 extern tree get_base_address (tree t);