OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa-dom.c
index 4e7a390..e2909e8 100644 (file)
@@ -134,10 +134,6 @@ static VEC(expr_hash_elt_t,heap) *avail_exprs_stack;
    expressions are removed from AVAIL_EXPRS.  Else we may change the
    hash code for an expression and be unable to find/remove it from
    AVAIL_EXPRS.  */
-typedef gimple *gimple_p;
-DEF_VEC_P(gimple_p);
-DEF_VEC_ALLOC_P(gimple_p,heap);
-
 static VEC(gimple_p,heap) *stmts_to_rescan;
 
 /* Structure for entries in the expression hash table.  */
@@ -381,8 +377,7 @@ hashable_expr_equal_p (const struct hashable_expr *expr0,
       if (expr0->ops.unary.op != expr1->ops.unary.op)
         return false;
 
-      if ((expr0->ops.unary.op == NOP_EXPR
-           || expr0->ops.unary.op == CONVERT_EXPR
+      if ((CONVERT_EXPR_CODE_P (expr0->ops.unary.op)
            || expr0->ops.unary.op == NON_LVALUE_EXPR)
           && TYPE_UNSIGNED (expr0->type) != TYPE_UNSIGNED (expr1->type))
         return false;
@@ -460,8 +455,7 @@ iterative_hash_hashable_expr (const struct hashable_expr *expr, hashval_t val)
          Don't hash the type, that can lead to having nodes which
          compare equal according to operand_equal_p, but which
          have different hash codes.  */
-      if (expr->ops.unary.op == NOP_EXPR
-          || expr->ops.unary.op == CONVERT_EXPR
+      if (CONVERT_EXPR_CODE_P (expr->ops.unary.op)
           || expr->ops.unary.op == NON_LVALUE_EXPR)
         val += TYPE_UNSIGNED (expr->type);
 
@@ -1843,7 +1837,7 @@ eliminate_redundant_computations (gimple_stmt_iterator* gsi)
   if (! def
       || TREE_CODE (def) != SSA_NAME
       || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (def)
-      || !ZERO_SSA_OPERANDS (stmt, SSA_OP_VDEF)
+      || gimple_vdef (stmt)
       /* Do not record equivalences for increments of ivs.  This would create
         overlapping live ranges for a very questionable gain.  */
       || simple_iv_increment_p (stmt))
@@ -1929,8 +1923,7 @@ static bool
 gimple_assign_unary_useless_conversion_p (gimple gs)
 {
   if (is_gimple_assign (gs)
-      && (gimple_assign_rhs_code (gs) == NOP_EXPR
-          || gimple_assign_rhs_code (gs) == CONVERT_EXPR
+      && (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (gs))
           || gimple_assign_rhs_code (gs) == VIEW_CONVERT_EXPR
           || gimple_assign_rhs_code (gs) == NON_LVALUE_EXPR))
     {
@@ -2024,7 +2017,7 @@ record_equivalences_from_stmt (gimple stmt, int may_optimize_p)
       else
         new_stmt = gimple_build_assign (rhs, lhs);
 
-      create_ssa_artificial_load_stmt (new_stmt, stmt, true);
+      gimple_set_vuse (new_stmt, gimple_vdef (stmt));
 
       /* Finally enter the statement into the available expression
         table.  */
@@ -2048,8 +2041,6 @@ cprop_operand (gimple stmt, use_operand_p op_p)
   val = SSA_NAME_VALUE (op);
   if (val && val != op)
     {
-      tree op_type, val_type;
-
       /* Do not change the base variable in the virtual operand
         tables.  That would make it impossible to reconstruct
         the renamed virtual operand if we later modify this
@@ -2066,38 +2057,20 @@ cprop_operand (gimple stmt, use_operand_p op_p)
          && !may_propagate_copy_into_asm (op))
        return false;
 
-      /* Get the toplevel type of each operand.  */
-      op_type = TREE_TYPE (op);
-      val_type = TREE_TYPE (val);
-
-      /* While both types are pointers, get the type of the object
-        pointed to.  */
-      while (POINTER_TYPE_P (op_type) && POINTER_TYPE_P (val_type))
-       {
-         op_type = TREE_TYPE (op_type);
-         val_type = TREE_TYPE (val_type);
-       }
-
-      /* Make sure underlying types match before propagating a constant by
-        converting the constant to the proper type.  Note that convert may
-        return a non-gimple expression, in which case we ignore this
-        propagation opportunity.  */
-      if (TREE_CODE (val) != SSA_NAME)
-       {
-         if (!useless_type_conversion_p (op_type, val_type))
-           {
-             val = fold_convert (TREE_TYPE (op), val);
-             if (!is_gimple_min_invariant (val))
-               return false;
-           }
-       }
-
       /* Certain operands are not allowed to be copy propagated due
         to their interaction with exception handling and some GCC
         extensions.  */
-      else if (!may_propagate_copy (op, val))
+      if (!may_propagate_copy (op, val))
        return false;
-      
+
+      /* Do not propagate addresses that point to volatiles into memory
+        stmts without volatile operands.  */
+      if (POINTER_TYPE_P (TREE_TYPE (val))
+         && TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (val)))
+         && gimple_has_mem_ops (stmt)
+         && !gimple_has_volatile_ops (stmt))
+       return false;
+
       /* Do not propagate copies if the propagated value is at a deeper loop
         depth than the propagatee.  Otherwise, this may move loop variant
         variables outside of their loops and prevent coalescing
@@ -2182,7 +2155,8 @@ optimize_stmt (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
 {
   gimple stmt, old_stmt;
   bool may_optimize_p;
-  bool may_have_exposed_new_symbols = false;
+  bool may_have_exposed_new_symbols;
+  bool modified_p = false;
 
   old_stmt = stmt = gsi_stmt (si);
   
@@ -2191,7 +2165,6 @@ optimize_stmt (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
   
   update_stmt_if_modified (stmt);
   opt_stats.num_stmts++;
-  may_have_exposed_new_symbols = false;
   push_stmt_changes (gsi_stmt_ptr (&si));
 
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -2240,6 +2213,10 @@ optimize_stmt (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
 
         Indicate we will need to rescan and rewrite the statement.  */
       may_have_exposed_new_symbols = true;
+      /* Indicate that maybe_clean_or_replace_eh_stmt needs to be called,
+        even if fold_stmt updated the stmt already and thus cleared
+        gimple_modified_p flag on it.  */
+      modified_p = true;
     }
 
   /* Check for redundant computations.  Do this optimization only
@@ -2288,7 +2265,7 @@ optimize_stmt (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
 
      Ultimately I suspect we're going to need to change the interface
      into the SSA_NAME manager.  */
-  if (gimple_modified_p (stmt))
+  if (gimple_modified_p (stmt) || modified_p)
     {
       tree val = NULL;
 
@@ -2424,7 +2401,6 @@ avail_expr_hash (const void *p)
   gimple stmt = ((const struct expr_hash_elt *)p)->stmt;
   const struct hashable_expr *expr = &((const struct expr_hash_elt *)p)->expr;
   tree vuse;
-  ssa_op_iter iter;
   hashval_t val = 0;
 
   val = iterative_hash_hashable_expr (expr, val);
@@ -2435,11 +2411,11 @@ avail_expr_hash (const void *p)
   if (!stmt)
     return val;
 
-  /* Add the SSA version numbers of every vuse operand.  This is important
+  /* Add the SSA version numbers of the vuse operand.  This is important
      because compound variables like arrays are not renamed in the
      operands.  Rather, the rename is done on the virtual variable
      representing all the elements of the array.  */
-  FOR_EACH_SSA_TREE_OPERAND (vuse, stmt, iter, SSA_OP_VUSE)
+  if ((vuse = gimple_vuse (stmt)))
     val = iterative_hash_expr (vuse, val);
 
   return val;
@@ -2481,8 +2457,8 @@ avail_expr_eq (const void *p1, const void *p2)
       && types_compatible_p (expr1->type, expr2->type))
     {
       /* Note that STMT1 and/or STMT2 may be NULL.  */
-      bool ret = compare_ssa_operands_equal (stmt1, stmt2, SSA_OP_VUSE);
-      return ret;
+      return ((stmt1 ? gimple_vuse (stmt1) : NULL_TREE)
+             == (stmt2 ? gimple_vuse (stmt2) : NULL_TREE));
     }
 
   return false;
@@ -2494,7 +2470,7 @@ avail_expr_eq (const void *p1, const void *p2)
 /* Given PHI, return its RHS if the PHI is a degenerate, otherwise return
    NULL.  */
 
-static tree
+tree
 degenerate_phi_result (gimple phi)
 {
   tree lhs = gimple_phi_result (phi);