OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa-dom.c
index 26df9ed..7b1c3ac 100644 (file)
@@ -223,14 +223,12 @@ static void record_cond (tree, tree, varray_type *);
 static void record_dominating_conditions (tree, varray_type *);
 static void record_const_or_copy (tree, tree, varray_type *);
 static void record_equality (tree, tree, varray_type *);
-static tree update_rhs_and_lookup_avail_expr (tree, tree, varray_type *,
-                                             stmt_ann_t, bool);
+static tree update_rhs_and_lookup_avail_expr (tree, tree, varray_type *, bool);
 static tree simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *,
-                                               tree, stmt_ann_t, int);
+                                               tree, int);
 static tree simplify_cond_and_lookup_avail_expr (tree, varray_type *,
                                                 stmt_ann_t, int);
-static tree simplify_switch_and_lookup_avail_expr (tree, varray_type *,
-                                                  stmt_ann_t, int);
+static tree simplify_switch_and_lookup_avail_expr (tree, varray_type *, int);
 static tree find_equivalent_equality_comparison (tree);
 static void record_range (tree, basic_block, varray_type *);
 static bool extract_range_from_cond (tree, tree *, tree *, int *);
@@ -255,7 +253,7 @@ static void restore_vars_to_original_value (varray_type locals,
                                            varray_type table);
 static void restore_currdefs_to_original_value (varray_type locals,
                                                unsigned limit);
-static void register_definitions_for_stmt (stmt_ann_t, varray_type *);
+static void register_definitions_for_stmt (tree, varray_type *);
 static edge single_incoming_edge_ignoring_loop_edges (basic_block);
 
 /* Local version of fold that doesn't introduce cruft.  */
@@ -434,7 +432,8 @@ struct tree_opt_pass pass_dominator =
   0,                                   /* properties_destroyed */
   0,                                   /* todo_flags_start */
   TODO_dump_func | TODO_rename_vars
-    | TODO_verify_ssa                  /* todo_flags_finish */
+    | TODO_verify_ssa,                 /* todo_flags_finish */
+  0                                    /* letter */
 };
 
 
@@ -652,10 +651,9 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
            cached_lhs = lookup_avail_expr (dummy_cond, NULL, false);
          if (!cached_lhs || ! is_gimple_min_invariant (cached_lhs))
            {
-             stmt_ann_t ann = get_stmt_ann (dummy_cond);
              cached_lhs = simplify_cond_and_lookup_avail_expr (dummy_cond,
                                                                NULL,
-                                                               ann,
+                                                               NULL,
                                                                false);
            }
        }
@@ -717,7 +715,6 @@ dom_opt_initialize_block_local_data (struct dom_walk_data *walk_data ATTRIBUTE_U
                                     basic_block bb ATTRIBUTE_UNUSED,
                                     bool recycled ATTRIBUTE_UNUSED)
 {
-#ifdef ENABLE_CHECKING
   struct dom_walk_block_data *bd
     = (struct dom_walk_block_data *)VARRAY_TOP_GENERIC_PTR (walk_data->block_data_stack);
 
@@ -727,20 +724,19 @@ dom_opt_initialize_block_local_data (struct dom_walk_data *walk_data ATTRIBUTE_U
      make sure we clear them before using them!  */
   if (recycled)
     {
-      if (bd->avail_exprs && VARRAY_ACTIVE_SIZE (bd->avail_exprs) > 0)
-       abort ();
-      if (bd->const_and_copies && VARRAY_ACTIVE_SIZE (bd->const_and_copies) > 0)
-       abort ();
-      if (bd->nonzero_vars && VARRAY_ACTIVE_SIZE (bd->nonzero_vars) > 0)
-       abort ();
-      if (bd->stmts_to_rescan && VARRAY_ACTIVE_SIZE (bd->stmts_to_rescan) > 0)
-       abort ();
-      if (bd->vrp_variables && VARRAY_ACTIVE_SIZE (bd->vrp_variables) > 0)
-       abort ();
-      if (bd->block_defs && VARRAY_ACTIVE_SIZE (bd->block_defs) > 0)
-       abort ();
+      gcc_assert (!bd->avail_exprs
+                 || VARRAY_ACTIVE_SIZE (bd->avail_exprs) == 0);
+      gcc_assert (!bd->const_and_copies
+                 || VARRAY_ACTIVE_SIZE (bd->const_and_copies) == 0);
+      gcc_assert (!bd->nonzero_vars
+                 || VARRAY_ACTIVE_SIZE (bd->nonzero_vars) == 0);
+      gcc_assert (!bd->stmts_to_rescan
+                 || VARRAY_ACTIVE_SIZE (bd->stmts_to_rescan) == 0);
+      gcc_assert (!bd->vrp_variables
+                 || VARRAY_ACTIVE_SIZE (bd->vrp_variables) == 0);
+      gcc_assert (!bd->block_defs
+                 || VARRAY_ACTIVE_SIZE (bd->block_defs) == 0);
     }
-#endif
 }
 
 /* Initialize local stacks for this optimizer and record equivalences
@@ -1628,9 +1624,7 @@ record_equality (tree x, tree y, varray_type *block_const_and_copies_p)
 
 static tree
 simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data,
-                                   tree stmt,
-                                   stmt_ann_t ann,
-                                   int insert)
+                                   tree stmt, int insert)
 {
   tree rhs = TREE_OPERAND (stmt, 1);
   enum tree_code rhs_code = TREE_CODE (rhs);
@@ -1663,7 +1657,6 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data,
            result = update_rhs_and_lookup_avail_expr (stmt,
                                                       rhs_def_operand,
                                                       &bd->avail_exprs,
-                                                      ann,
                                                       insert);
        }
     }
@@ -1748,7 +1741,7 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data,
                          && TREE_CODE (TREE_OPERAND (t, 0)) == SSA_NAME
                          && is_gimple_val (TREE_OPERAND (t, 1))))
                    result = update_rhs_and_lookup_avail_expr
-                     (stmt, t, &bd->avail_exprs, ann, insert);
+                     (stmt, t, &bd->avail_exprs, insert);
                }
            }
        }
@@ -1801,15 +1794,14 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data,
 
          if (rhs_code == TRUNC_DIV_EXPR)
            t = build (RSHIFT_EXPR, TREE_TYPE (op0), op0,
-                      build_int_2 (tree_log2 (op1), 0));
+                      build_int_cst (NULL_TREE, tree_log2 (op1)));
          else
            t = build (BIT_AND_EXPR, TREE_TYPE (op0), op0,
                       local_fold (build (MINUS_EXPR, TREE_TYPE (op1),
                                          op1, integer_one_node)));
 
          result = update_rhs_and_lookup_avail_expr (stmt, t,
-                                                    &bd->avail_exprs,
-                                                    ann, insert);
+                                                    &bd->avail_exprs, insert);
        }
     }
 
@@ -1842,7 +1834,7 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data,
              TREE_SET_CODE (TREE_OPERAND (dummy_cond, 0), LE_EXPR);
              TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 0) = op;
              TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 1)
-               = fold_convert (type, integer_zero_node);
+               = build_int_cst (type, 0);
            }
          val = simplify_cond_and_lookup_avail_expr (dummy_cond,
                                                     &bd->avail_exprs,
@@ -1853,7 +1845,7 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data,
              TREE_SET_CODE (TREE_OPERAND (dummy_cond, 0), GE_EXPR);
              TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 0) = op;
              TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 1)
-               = fold_convert (type, integer_zero_node);
+               = build_int_cst (type, 0);
 
              val = simplify_cond_and_lookup_avail_expr (dummy_cond,
                                                         &bd->avail_exprs,
@@ -1880,8 +1872,7 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data,
            t = op;
 
          result = update_rhs_and_lookup_avail_expr (stmt, t,
-                                                    &bd->avail_exprs,
-                                                    ann, insert);
+                                                    &bd->avail_exprs, insert);
        }
     }
 
@@ -1893,8 +1884,7 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data,
 
       if (t)
         result = update_rhs_and_lookup_avail_expr (stmt, t,
-                                                  &bd->avail_exprs,
-                                                  ann, insert);
+                                                  &bd->avail_exprs, insert);
     }
 
   return result;
@@ -2001,7 +1991,11 @@ simplify_cond_and_lookup_avail_expr (tree stmt,
                  /* Update the statement to use the new equivalent
                     condition.  */
                  COND_EXPR_COND (stmt) = new_cond;
-                 ann->modified = 1;
+
+                 /* If this is not a real stmt, ann will be NULL and we
+                    avoid processing the operands.  */
+                 if (ann)
+                   modify_stmt (stmt);
 
                  /* Lookup the condition and return its known value if it
                     exists.  */
@@ -2197,7 +2191,6 @@ simplify_cond_and_lookup_avail_expr (tree stmt,
 static tree
 simplify_switch_and_lookup_avail_expr (tree stmt,
                                       varray_type *block_avail_exprs_p,
-                                      stmt_ann_t ann,
                                       int insert)
 {
   tree cond = SWITCH_COND (stmt);
@@ -2221,8 +2214,7 @@ simplify_switch_and_lookup_avail_expr (tree stmt,
 
 #ifdef ENABLE_CHECKING
              /* ??? Why was Jeff testing this?  We are gimple...  */
-             if (!is_gimple_val (def))
-               abort ();
+             gcc_assert (is_gimple_val (def));
 #endif
 
              to = TREE_TYPE (cond);
@@ -2243,7 +2235,7 @@ simplify_switch_and_lookup_avail_expr (tree stmt,
              if (!fail)
                {
                  SWITCH_COND (stmt) = def;
-                 ann->modified = 1;
+                 modify_stmt (stmt);
 
                  return lookup_avail_expr (stmt, block_avail_exprs_p, insert);
                }
@@ -2321,12 +2313,9 @@ cprop_into_successor_phis (basic_block bb,
              hint = i;
            }
 
-#ifdef ENABLE_CHECKING
          /* If we did not find the proper alternative, then something is
             horribly wrong.  */
-         if (hint == phi_num_args)
-           abort ();
-#endif
+         gcc_assert (hint != phi_num_args);
 
          /* The alternative may be associated with a constant, so verify
             it is an SSA_NAME before doing anything with it.  */
@@ -2404,7 +2393,6 @@ eliminate_redundant_computations (struct dom_walk_data *walk_data,
   if (! cached_lhs && TREE_CODE (stmt) == MODIFY_EXPR)
     cached_lhs = simplify_rhs_and_lookup_avail_expr (walk_data,
                                                     stmt,
-                                                    ann,
                                                     insert);
   /* Similarly if this is a COND_EXPR and we did not find its
      expression in the hash table, simplify the condition and
@@ -2418,7 +2406,6 @@ eliminate_redundant_computations (struct dom_walk_data *walk_data,
   else if (!cached_lhs && TREE_CODE (stmt) == SWITCH_EXPR)
     cached_lhs = simplify_switch_and_lookup_avail_expr (stmt,
                                                        &bd->avail_exprs,
-                                                       ann,
                                                        insert);
 
   opt_stats.num_exprs_considered++;
@@ -2454,9 +2441,8 @@ eliminate_redundant_computations (struct dom_walk_data *walk_data,
       opt_stats.num_re++;
 
 #if defined ENABLE_CHECKING
-      if (TREE_CODE (cached_lhs) != SSA_NAME
-         && !is_gimple_min_invariant (cached_lhs))
-       abort ();
+      gcc_assert (TREE_CODE (cached_lhs) == SSA_NAME
+                 || is_gimple_min_invariant (cached_lhs));
 #endif
 
       if (TREE_CODE (cached_lhs) == ADDR_EXPR
@@ -2465,7 +2451,7 @@ eliminate_redundant_computations (struct dom_walk_data *walk_data,
        retval = true;
 
       propagate_tree_value (expr_p, cached_lhs);
-      ann->modified = 1;
+      modify_stmt (stmt);
     }
   return retval;
 }
@@ -2572,7 +2558,6 @@ record_equivalences_from_stmt (tree stmt,
     {
       tree rhs = TREE_OPERAND (stmt, 1);
       tree new;
-      size_t j;
 
       /* FIXME: If the LHS of the assignment is a bitfield and the RHS
          is a constant, we need to adjust the constant to fit into the
@@ -2597,39 +2582,10 @@ record_equivalences_from_stmt (tree stmt,
 
       if (rhs)
        {
-         v_may_def_optype v_may_defs = V_MAY_DEF_OPS (ann);
-         v_must_def_optype v_must_defs = V_MUST_DEF_OPS (ann);
-
          /* Build a new statement with the RHS and LHS exchanged.  */
          new = build (MODIFY_EXPR, TREE_TYPE (stmt), rhs, lhs);
 
-         /* Get an annotation and set up the real operands.  */
-         get_stmt_ann (new);
-         get_stmt_operands (new);
-
-         /* Clear out the virtual operands on the new statement, we are
-            going to set them explicitly below.  */
-         remove_vuses (new);
-         remove_v_may_defs (new);
-         remove_v_must_defs (new);
-
-         start_ssa_stmt_operands (new);
-         /* For each VDEF on the original statement, we want to create a
-            VUSE of the V_MAY_DEF result or V_MUST_DEF op on the new 
-            statement.  */
-         for (j = 0; j < NUM_V_MAY_DEFS (v_may_defs); j++)
-           {
-             tree op = V_MAY_DEF_RESULT (v_may_defs, j);
-             add_vuse (op, new);
-           }
-           
-         for (j = 0; j < NUM_V_MUST_DEFS (v_must_defs); j++)
-           {
-             tree op = V_MUST_DEF_OP (v_must_defs, j);
-             add_vuse (op, new);
-           }
-
-         finalize_ssa_stmt_operands (new);
+         create_ssa_artficial_load_stmt (&(ann->operands), new);
 
          /* Finally enter the statement into the available expression
             table.  */
@@ -2642,7 +2598,7 @@ record_equivalences_from_stmt (tree stmt,
    CONST_AND_COPIES.  */
 
 static bool
-cprop_operand (stmt_ann_t ann, use_operand_p op_p, varray_type const_and_copies)
+cprop_operand (tree stmt, use_operand_p op_p, varray_type const_and_copies)
 {
   bool may_have_exposed_new_symbols = false;
   tree val;
@@ -2721,7 +2677,7 @@ cprop_operand (stmt_ann_t ann, use_operand_p op_p, varray_type const_and_copies)
       /* And note that we modified this statement.  This is now
         safe, even if we changed virtual operands since we will
         rescan the statement and rewrite its operands again.  */
-      ann->modified = 1;
+      modify_stmt (stmt);
     }
   return may_have_exposed_new_symbols;
 }
@@ -2736,41 +2692,16 @@ static bool
 cprop_into_stmt (tree stmt, varray_type const_and_copies)
 {
   bool may_have_exposed_new_symbols = false;
-  stmt_ann_t ann = stmt_ann (stmt);
-  size_t i, num_uses, num_vuses, num_v_may_defs;
-  vuse_optype vuses;
-  v_may_def_optype v_may_defs;
-  use_optype uses;
+  use_operand_p op_p;
+  ssa_op_iter iter;
 
-  uses = USE_OPS (ann);
-  num_uses = NUM_USES (uses);
-  for (i = 0; i < num_uses; i++)
+  FOR_EACH_SSA_USE_OPERAND (op_p, stmt, iter, SSA_OP_ALL_USES)
     {
-      use_operand_p op_p = USE_OP_PTR (uses, i);
       if (TREE_CODE (USE_FROM_PTR (op_p)) == SSA_NAME)
        may_have_exposed_new_symbols
-         |= cprop_operand (ann, op_p, const_and_copies);
+         |= cprop_operand (stmt, op_p, const_and_copies);
     }
 
-  vuses = VUSE_OPS (ann);
-  num_vuses = NUM_VUSES (vuses);
-  for (i = 0; i < num_vuses; i++)
-    {
-      use_operand_p op_p = VUSE_OP_PTR (vuses, i);
-      if (TREE_CODE (USE_FROM_PTR (op_p)) == SSA_NAME)
-       may_have_exposed_new_symbols
-         |= cprop_operand (ann, op_p, const_and_copies);
-    }
-
-  v_may_defs = V_MAY_DEF_OPS (ann);
-  num_v_may_defs = NUM_V_MAY_DEFS (v_may_defs);
-  for (i = 0; i < num_v_may_defs; i++)
-    {
-      use_operand_p op_p = V_MAY_DEF_OP_PTR (v_may_defs, i);
-      if (TREE_CODE (USE_FROM_PTR (op_p)) == SSA_NAME)
-       may_have_exposed_new_symbols
-         |= cprop_operand (ann, op_p, const_and_copies);
-    }
   return may_have_exposed_new_symbols;
 }
 
@@ -2868,7 +2799,7 @@ optimize_stmt (struct dom_walk_data *walk_data, basic_block bb,
                                   may_optimize_p,
                                   ann);
 
-  register_definitions_for_stmt (ann, &bd->block_defs);
+  register_definitions_for_stmt (stmt, &bd->block_defs);
 
   /* If STMT is a COND_EXPR and it was modified, then we may know
      where it goes.  If that is the case, then mark the CFG as altered.
@@ -2936,7 +2867,6 @@ optimize_stmt (struct dom_walk_data *walk_data, basic_block bb,
 static tree
 update_rhs_and_lookup_avail_expr (tree stmt, tree new_rhs, 
                                  varray_type *block_avail_exprs_p,
-                                 stmt_ann_t ann,
                                  bool insert)
 {
   tree cached_lhs = NULL;
@@ -2982,7 +2912,7 @@ update_rhs_and_lookup_avail_expr (tree stmt, tree new_rhs,
 
   /* And make sure we record the fact that we modified this
      statement.  */
-  ann->modified = 1;
+  modify_stmt (stmt);
 
   return cached_lhs;
 }
@@ -3396,11 +3326,8 @@ avail_expr_eq (const void *p1, const void *p2)
        if (VUSE_OP (ops1, i) != VUSE_OP (ops2, i))
          return false;
 
-#ifdef ENABLE_CHECKING
-      if (((struct expr_hash_elt *)p1)->hash
-         != ((struct expr_hash_elt *)p2)->hash)
-       abort ();
-#endif
+      gcc_assert (((struct expr_hash_elt *)p1)->hash
+                 == ((struct expr_hash_elt *)p2)->hash);
       return true;
     }
 
@@ -3412,39 +3339,17 @@ avail_expr_eq (const void *p1, const void *p2)
    and CURRDEFS.  */
 
 static void
-register_definitions_for_stmt (stmt_ann_t ann, varray_type *block_defs_p)
+register_definitions_for_stmt (tree stmt, varray_type *block_defs_p)
 {
-  def_optype defs;
-  v_may_def_optype v_may_defs;
-  v_must_def_optype v_must_defs;
-  unsigned int i;
+  tree def;
+  ssa_op_iter iter;
 
-  defs = DEF_OPS (ann);
-  for (i = 0; i < NUM_DEFS (defs); i++)
+  FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_ALL_DEFS)
     {
-      tree def = DEF_OP (defs, i);
 
       /* FIXME: We shouldn't be registering new defs if the variable
         doesn't need to be renamed.  */
       register_new_def (def, block_defs_p);
     }
-
-  /* Register new virtual definitions made by the statement.  */
-  v_may_defs = V_MAY_DEF_OPS (ann);
-  for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++)
-    {
-      /* FIXME: We shouldn't be registering new defs if the variable
-        doesn't need to be renamed.  */
-      register_new_def (V_MAY_DEF_RESULT (v_may_defs, i), block_defs_p);
-    }
-    
-  /* Register new virtual mustdefs made by the statement.  */
-  v_must_defs = V_MUST_DEF_OPS (ann);
-  for (i = 0; i < NUM_V_MUST_DEFS (v_must_defs); i++)
-    {
-      /* FIXME: We shouldn't be registering new defs if the variable
-        doesn't need to be renamed.  */
-      register_new_def (V_MUST_DEF_OP (v_must_defs, i), block_defs_p);
-    }
 }