OSDN Git Service

2007-01-24 Andrew Haley <aph@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa-forwprop.c
index a5267ae..ca1d0a8 100644 (file)
@@ -490,15 +490,16 @@ find_equivalent_equality_comparison (tree cond)
   return NULL;
 }
 
-/* STMT is a COND_EXPR
+/* EXPR is a COND_EXPR
+   STMT is the statement containing EXPR.
 
    This routine attempts to find equivalent forms of the condition
    which we may be able to optimize better.  */
 
 static void
-simplify_cond (tree stmt)
+simplify_cond (tree cond_expr, tree stmt)
 {
-  tree cond = COND_EXPR_COND (stmt);
+  tree cond = COND_EXPR_COND (cond_expr);
 
   if (COMPARISON_CLASS_P (cond))
     {
@@ -517,7 +518,7 @@ simplify_cond (tree stmt)
 
              if (new_cond)
                {
-                 COND_EXPR_COND (stmt) = new_cond;
+                 COND_EXPR_COND (cond_expr) = new_cond;
                  update_stmt (stmt);
                }
            }
@@ -529,7 +530,7 @@ simplify_cond (tree stmt)
    times as possible.  */
 
 static void
-forward_propagate_into_cond (tree cond_expr)
+forward_propagate_into_cond (tree cond_expr, tree stmt)
 {
   gcc_assert (TREE_CODE (cond_expr) == COND_EXPR);
 
@@ -554,7 +555,7 @@ forward_propagate_into_cond (tree cond_expr)
        }
 
       COND_EXPR_COND (cond_expr) = new_cond;
-      update_stmt (cond_expr);
+      update_stmt (stmt);
 
       if (has_zero_uses (test_var))
        {
@@ -570,7 +571,7 @@ forward_propagate_into_cond (tree cond_expr)
      against a constant where the SSA_NAME is the result of a
      conversion.  Perhaps this should be folded into the rest
      of the COND_EXPR simplification code.  */
-  simplify_cond (cond_expr);
+  simplify_cond (cond_expr, stmt);
 }
 
 /* We've just substituted an ADDR_EXPR into stmt.  Update all the 
@@ -1016,6 +1017,11 @@ tree_ssa_forward_propagate_single_use_vars (void)
                  simplify_not_neg_expr (stmt);
                  bsi_next (&bsi);
                }
+              else if (TREE_CODE (rhs) == COND_EXPR)
+                {
+                  forward_propagate_into_cond (rhs, stmt);
+                 bsi_next (&bsi);
+                }
              else
                bsi_next (&bsi);
            }
@@ -1026,7 +1032,7 @@ tree_ssa_forward_propagate_single_use_vars (void)
            }
          else if (TREE_CODE (stmt) == COND_EXPR)
            {
-             forward_propagate_into_cond (stmt);
+             forward_propagate_into_cond (stmt, stmt);
              bsi_next (&bsi);
            }
          else
@@ -1035,7 +1041,7 @@ tree_ssa_forward_propagate_single_use_vars (void)
     }
 
   if (cfg_changed)
-    cleanup_tree_cfg ();
+    todoflags |= TODO_cleanup_cfg;
   return todoflags;
 }
 
@@ -1054,8 +1060,7 @@ struct tree_opt_pass pass_forwprop = {
   NULL,                                /* next */
   0,                           /* static_pass_number */
   TV_TREE_FORWPROP,            /* tv_id */
-  PROP_cfg | PROP_ssa
-    | PROP_alias,              /* properties_required */
+  PROP_cfg | PROP_ssa,         /* properties_required */
   0,                           /* properties_provided */
   0,                           /* properties_destroyed */
   0,                           /* todo_flags_start */