OSDN Git Service

2004-11-16 Eric Christopher <echristo@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa-pre.c
index bfe39f4..113ec83 100644 (file)
@@ -363,7 +363,7 @@ expr_pred_trans_eq (const void *p1, const void *p2)
     return false;
 
   /* If they are for the same basic block, determine if the
-     expressions are equal.   */  
+     expressions are equal.  */  
   if (expressions_equal_p (ve1->e, ve2->e))
     return true;
   
@@ -768,17 +768,21 @@ bitmap_print_value_set (FILE *outfile, bitmap_set_t set,
   fprintf (outfile, "%s[%d] := { ", setname, blockindex);
   if (set)
     {
-      int i;
-      EXECUTE_IF_SET_IN_BITMAP (set->expressions, 0, i,
-      {
-       print_generic_expr (outfile, ssa_name (i), 0);
+      bool first = true;
+      unsigned i;
+      bitmap_iterator bi;
+
+      EXECUTE_IF_SET_IN_BITMAP (set->expressions, 0, i, bi)
+       {
+         if (!first)
+           fprintf (outfile, ", ");
+         first = false;
+         print_generic_expr (outfile, ssa_name (i), 0);
        
-       fprintf (outfile, " (");
-       print_generic_expr (outfile, get_value_handle (ssa_name (i)), 0);
-       fprintf (outfile, ") ");
-       if (bitmap_last_set_bit (set->expressions) != i)
-         fprintf (outfile, ", ");
-      });
+         fprintf (outfile, " (");
+         print_generic_expr (outfile, get_value_handle (ssa_name (i)), 0);
+         fprintf (outfile, ") ");
+       }
     }
   fprintf (outfile, " }\n");
 }
@@ -856,7 +860,7 @@ phi_translate (tree expr, value_set_t set, basic_block pred,
   if (is_gimple_min_invariant (expr))
     return expr;
 
-  /* Phi translations of a given expression don't change,  */
+  /* Phi translations of a given expression don't change.  */
   phitrans = phi_trans_lookup (expr, pred);
   if (phitrans)
     return phitrans;
@@ -864,7 +868,7 @@ phi_translate (tree expr, value_set_t set, basic_block pred,
   switch (TREE_CODE_CLASS (TREE_CODE (expr)))
     {
     case tcc_reference:
-      /* XXX: Until we have PRE of loads working, none will be ANTIC. */
+      /* XXX: Until we have PRE of loads working, none will be ANTIC.  */
       return NULL;
 
     case tcc_binary:
@@ -1135,12 +1139,13 @@ compute_antic_aux (basic_block block)
      setting the BB_VISITED flag.  */
   if (! (block->flags & BB_VISITED))
     {
-      for (e = block->pred; e; e = e->pred_next)
-       if (e->flags & EDGE_ABNORMAL)
-         {
-           block->flags |= BB_VISITED;
-           break;
-         }
+      edge_iterator ei;
+      FOR_EACH_EDGE (e, ei, block->preds)
+       if (e->flags & EDGE_ABNORMAL)
+         {
+           block->flags |= BB_VISITED;
+           break;
+         }
     }
   if (block->flags & BB_VISITED)
     {
@@ -1155,14 +1160,14 @@ compute_antic_aux (basic_block block)
 
   /* If the block has no successors, ANTIC_OUT is empty, because it is
      the exit block.  */
-  if (block->succ == NULL);
+  if (EDGE_COUNT (block->succs) == 0);
 
   /* If we have one successor, we could have some phi nodes to
      translate through.  */
-  else if (block->succ->succ_next == NULL)
+  else if (EDGE_COUNT (block->succs) == 1)
     {
-      phi_translate_set (ANTIC_OUT, ANTIC_IN(block->succ->dest),
-                        block, block->succ->dest);
+      phi_translate_set (ANTIC_OUT, ANTIC_IN(EDGE_SUCC (block, 0)->dest),
+                        block, EDGE_SUCC (block, 0)->dest);
     }
   /* If we have multiple successors, we take the intersection of all of
      them.  */
@@ -1172,14 +1177,11 @@ compute_antic_aux (basic_block block)
       edge e;
       size_t i;
       basic_block bprime, first;
+      edge_iterator ei;
 
       worklist = VEC_alloc (basic_block, 2);
-      e = block->succ;
-      while (e)
-       {
-         VEC_safe_push (basic_block, worklist, e->dest);
-         e = e->succ_next;
-       }
+      FOR_EACH_EDGE (e, ei, block->succs)
+       VEC_safe_push (basic_block, worklist, e->dest);
       first = VEC_index (basic_block, worklist, 0);
       set_copy (ANTIC_OUT, ANTIC_IN (first));
 
@@ -1199,7 +1201,7 @@ compute_antic_aux (basic_block block)
       VEC_free (basic_block, worklist);
     }
 
-  /* Generate ANTIC_OUT - TMP_GEN */
+  /* Generate ANTIC_OUT - TMP_GEN */
   S = bitmap_set_subtract_from_value_set (ANTIC_OUT, TMP_GEN (block), false);
 
   /* Start ANTIC_IN with EXP_GEN - TMP_GEN */
@@ -1415,14 +1417,16 @@ insert_aux (basic_block block)
       dom = get_immediate_dominator (CDI_DOMINATORS, block);
       if (dom)
        {
-         int i;
+         unsigned i;
+         bitmap_iterator bi;
+
          bitmap_set_t newset = NEW_SETS (dom);
-         EXECUTE_IF_SET_IN_BITMAP (newset->expressions, 0, i,
-          {
-           bitmap_insert_into_set (NEW_SETS (block), ssa_name (i));
-           bitmap_value_replace_in_set (AVAIL_OUT (block), ssa_name (i));
-         });
-         if (block->pred->pred_next)
+         EXECUTE_IF_SET_IN_BITMAP (newset->expressions, 0, i, bi)
+           {
+             bitmap_insert_into_set (NEW_SETS (block), ssa_name (i));
+             bitmap_value_replace_in_set (AVAIL_OUT (block), ssa_name (i));
+           }
+         if (EDGE_COUNT (block->preds) > 1)
            {
              value_set_node_t node;
              for (node = ANTIC_IN (block)->head;
@@ -1441,6 +1445,7 @@ insert_aux (basic_block block)
                      edge pred;
                      basic_block bprime;
                      tree eprime;
+                     edge_iterator ei;
 
                      val = get_value_handle (node->expr);
                      if (bitmap_set_contains_value (PHI_GEN (block), val))
@@ -1451,11 +1456,9 @@ insert_aux (basic_block block)
                            fprintf (dump_file, "Found fully redundant value\n");
                          continue;
                        }
-                                   
+                                             
                      avail = xcalloc (last_basic_block, sizeof (tree));
-                     for (pred = block->pred;
-                          pred;
-                          pred = pred->pred_next)
+                     FOR_EACH_EDGE (pred, ei, block->preds)
                        {
                          tree vprime;
                          tree edoubleprime;
@@ -1516,7 +1519,7 @@ insert_aux (basic_block block)
                         partially redundant.  */
                      if (!cant_insert && !all_same && by_some)
                        {
-                         tree type = TREE_TYPE (avail[block->pred->src->index]);
+                         tree type = TREE_TYPE (avail[EDGE_PRED (block, 0)->src->index]);
                          tree temp;
                          if (dump_file && (dump_flags & TDF_DETAILS))
                            {
@@ -1526,9 +1529,7 @@ insert_aux (basic_block block)
                            }
 
                          /* Make the necessary insertions.  */
-                         for (pred = block->pred;
-                              pred;
-                              pred = pred->pred_next)
+                         FOR_EACH_EDGE (pred, ei, block->preds)
                            {
                              tree stmts = alloc_stmt_list ();
                              tree builtexpr;
@@ -1543,7 +1544,7 @@ insert_aux (basic_block block)
                                  bsi_insert_on_edge (pred, stmts);
                                  avail[bprime->index] = builtexpr;
                                }                             
-                           } 
+                           }
                          /* Now build a phi for the new variable.  */
                          temp = create_tmp_var (type, "prephitmp");
                          add_referenced_tmp_var (temp);
@@ -1558,9 +1559,7 @@ insert_aux (basic_block block)
 #endif
                            bitmap_value_replace_in_set (AVAIL_OUT (block), 
                                                         PHI_RESULT (temp));
-                         for (pred = block->pred;
-                              pred;
-                              pred = pred->pred_next)
+                         FOR_EACH_EDGE (pred, ei, block->preds)
                            {
                              add_phi_arg (&temp, avail[pred->src->index],
                                           pred);
@@ -1627,8 +1626,7 @@ is_undefined_value (tree expr)
   return (TREE_CODE (expr) == SSA_NAME
           && IS_EMPTY_STMT (SSA_NAME_DEF_STMT (expr))
          /* PARM_DECLs and hard registers are always defined.  */
-         && TREE_CODE (SSA_NAME_VAR (expr)) != PARM_DECL
-         && !DECL_HARD_REGISTER (SSA_NAME_VAR (expr)));
+         && TREE_CODE (SSA_NAME_VAR (expr)) != PARM_DECL);
 }
 
 
@@ -1922,9 +1920,9 @@ init_pre (void)
      ENTRY_BLOCK_PTR (FIXME, if ENTRY_BLOCK_PTR had an index number
      different than -1 we wouldn't have to hack this.  tree-ssa-dce.c
      needs a similar change).  */
-  if (ENTRY_BLOCK_PTR->succ->dest->pred->pred_next)
-    if (!(ENTRY_BLOCK_PTR->succ->flags & EDGE_ABNORMAL))
-      split_edge (ENTRY_BLOCK_PTR->succ);
+  if (EDGE_COUNT (EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest->preds) > 1)
+    if (!(EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->flags & EDGE_ABNORMAL))
+      split_edge (EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
 
   FOR_ALL_BB (bb)
     bb->aux = xcalloc (1, sizeof (struct bb_value_sets));
@@ -1945,7 +1943,7 @@ init_pre (void)
   unary_node_pool = create_alloc_pool ("Unary tree nodes",
                                       tree_code_size (NEGATE_EXPR), 30);
   reference_node_pool = create_alloc_pool ("Reference tree nodes",
-                                          tree_code_size (COMPONENT_REF), 30);
+                                          tree_code_size (ARRAY_REF), 30);
   FOR_ALL_BB (bb)
     {
       EXP_GEN (bb) = set_new (true);
@@ -1966,7 +1964,7 @@ fini_pre (void)
   basic_block bb;
   unsigned int i;
 
-  bsi_commit_edge_inserts (NULL);
+  bsi_commit_edge_inserts ();
 
   obstack_free (&grand_bitmap_obstack, NULL);
   free_alloc_pool (value_set_pool);
@@ -1987,7 +1985,7 @@ fini_pre (void)
   free_dominance_info (CDI_POST_DOMINATORS);
   vn_delete ();
 
-  if (bitmap_first_set_bit (need_eh_cleanup) >= 0)
+  if (!bitmap_empty_p (need_eh_cleanup))
     {
       tree_purge_all_dead_eh_edges (need_eh_cleanup);
       cleanup_tree_cfg ();