aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-forwprop.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-forwprop.c')
-rw-r--r--gcc/tree-ssa-forwprop.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 7dd5e08..89d6239 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -540,12 +540,9 @@ forward_propagate_into_gimple_cond (gimple stmt)
/* Propagate from the ssa name definition statements of COND_EXPR
in the rhs of statement STMT into the conditional if that simplifies it.
- Returns zero if no statement was changed, one if there were
- changes and two if cfg_cleanup needs to run.
-
- This must be kept in sync with forward_propagate_into_gimple_cond. */
+ Returns true zero if the stmt was changed. */
-static int
+static bool
forward_propagate_into_cond (gimple_stmt_iterator *gsi_p)
{
gimple stmt = gsi_stmt (*gsi_p);
@@ -560,15 +557,17 @@ forward_propagate_into_cond (gimple_stmt_iterator *gsi_p)
TREE_OPERAND (cond, 1));
else if (TREE_CODE (cond) == SSA_NAME)
{
- tree name = cond, rhs0;
+ tree name = cond;
gimple def_stmt = get_prop_source_stmt (name, true, NULL);
if (!def_stmt || !can_propagate_from (def_stmt))
return 0;
- rhs0 = gimple_assign_rhs1 (def_stmt);
- tmp = combine_cond_expr_cond (stmt, NE_EXPR, boolean_type_node, rhs0,
- build_int_cst (TREE_TYPE (rhs0), 0),
- false);
+ if (TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)) == tcc_comparison)
+ tmp = fold_build2_loc (gimple_location (def_stmt),
+ gimple_assign_rhs_code (def_stmt),
+ boolean_type_node,
+ gimple_assign_rhs1 (def_stmt),
+ gimple_assign_rhs2 (def_stmt));
}
if (tmp)
@@ -582,11 +581,16 @@ forward_propagate_into_cond (gimple_stmt_iterator *gsi_p)
fprintf (dump_file, "'\n");
}
- gimple_assign_set_rhs_from_tree (gsi_p, unshare_expr (tmp));
+ if (integer_onep (tmp))
+ gimple_assign_set_rhs_from_tree (gsi_p, gimple_assign_rhs2 (stmt));
+ else if (integer_zerop (tmp))
+ gimple_assign_set_rhs_from_tree (gsi_p, gimple_assign_rhs3 (stmt));
+ else
+ gimple_assign_set_rhs1 (stmt, unshare_expr (tmp));
stmt = gsi_stmt (*gsi_p);
update_stmt (stmt);
- return is_gimple_min_invariant (tmp) ? 2 : 1;
+ return true;
}
return 0;
@@ -2436,12 +2440,8 @@ ssa_forward_propagate_and_combine (void)
else if (code == COND_EXPR)
{
/* In this case the entire COND_EXPR is in rhs1. */
- int did_something;
- did_something = forward_propagate_into_cond (&gsi);
+ changed |= forward_propagate_into_cond (&gsi);
stmt = gsi_stmt (gsi);
- if (did_something == 2)
- cfg_changed = true;
- changed = did_something != 0;
}
else if (TREE_CODE_CLASS (code) == tcc_comparison)
{