diff options
author | Roberto Costa <roberto.costa@st.com> | 2007-01-08 13:52:42 +0000 |
---|---|---|
committer | Roberto Costa <robc@gcc.gnu.org> | 2007-01-08 13:52:42 +0000 |
commit | f255541fb7bdd1b1da1a8c661967021164fa515b (patch) | |
tree | dcb7083fc910095eb2aebe069e3d37af32897742 /gcc/tree-ssa-forwprop.c | |
parent | feb8476ac4b9534b99b222ff42ea40900fd7bfe3 (diff) | |
download | gcc-f255541fb7bdd1b1da1a8c661967021164fa515b.zip gcc-f255541fb7bdd1b1da1a8c661967021164fa515b.tar.gz gcc-f255541fb7bdd1b1da1a8c661967021164fa515b.tar.bz2 |
Better handling of COND_EXPRs in rhs
From-SVN: r120581
Diffstat (limited to 'gcc/tree-ssa-forwprop.c')
-rw-r--r-- | gcc/tree-ssa-forwprop.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index a5267ae..39653fc 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -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 |