aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dom.c
diff options
context:
space:
mode:
authorAndrew Pinski <pinskia@physics.uc.edu>2005-07-12 17:00:00 +0000
committerAndrew Pinski <pinskia@gcc.gnu.org>2005-07-12 10:00:00 -0700
commit019b02f12fe985b0ba72565e4d10b33c62c7836b (patch)
treec39f3b9fab9934e1ec06ced5284810a086b3827b /gcc/tree-ssa-dom.c
parenta207780f9b958e8cf857858a658dbe9db6b68347 (diff)
downloadgcc-019b02f12fe985b0ba72565e4d10b33c62c7836b.zip
gcc-019b02f12fe985b0ba72565e4d10b33c62c7836b.tar.gz
gcc-019b02f12fe985b0ba72565e4d10b33c62c7836b.tar.bz2
re PR tree-optimization/22335 (DOM creates mis-matched types)
2005-07-12 Andrew Pinski <pinskia@physics.uc.edu> PR tree-opt/22335 * tree-ssa-dom.c (eliminate_redundant_computations): Reject the prop if requiring a cast in a non RHS of modify_expr. Add a cast when required. (lookup_avail_expr): Use constant_boolean_node instead of boolean_false_node/boolean_true_node. From-SVN: r101929
Diffstat (limited to 'gcc/tree-ssa-dom.c')
-rw-r--r--gcc/tree-ssa-dom.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index e341a68..1b8b8f1 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -2506,6 +2506,7 @@ eliminate_redundant_computations (tree stmt, stmt_ann_t ann)
bool insert = true;
tree cached_lhs;
bool retval = false;
+ bool modify_expr_p = false;
if (TREE_CODE (stmt) == MODIFY_EXPR)
def = TREE_OPERAND (stmt, 0);
@@ -2547,9 +2548,15 @@ eliminate_redundant_computations (tree stmt, stmt_ann_t ann)
else if (TREE_CODE (stmt) == SWITCH_EXPR)
expr_p = &SWITCH_COND (stmt);
else if (TREE_CODE (stmt) == RETURN_EXPR && TREE_OPERAND (stmt, 0))
- expr_p = &TREE_OPERAND (TREE_OPERAND (stmt, 0), 1);
+ {
+ expr_p = &TREE_OPERAND (TREE_OPERAND (stmt, 0), 1);
+ modify_expr_p = true;
+ }
else
- expr_p = &TREE_OPERAND (stmt, 1);
+ {
+ expr_p = &TREE_OPERAND (stmt, 1);
+ modify_expr_p = true;
+ }
/* It is safe to ignore types here since we have already done
type checking in the hashing and equality routines. In fact
@@ -2557,7 +2564,10 @@ eliminate_redundant_computations (tree stmt, stmt_ann_t ann)
propagation. Also, make sure that it is safe to propagate
CACHED_LHS into *EXPR_P. */
if (cached_lhs
- && (TREE_CODE (cached_lhs) != SSA_NAME
+ && ((TREE_CODE (cached_lhs) != SSA_NAME
+ && (modify_expr_p
+ || tree_ssa_useless_type_conversion_1 (TREE_TYPE (*expr_p),
+ TREE_TYPE (cached_lhs))))
|| may_propagate_copy (*expr_p, cached_lhs)))
{
if (dump_file && (dump_flags & TDF_DETAILS))
@@ -2580,6 +2590,11 @@ eliminate_redundant_computations (tree stmt, stmt_ann_t ann)
|| (POINTER_TYPE_P (TREE_TYPE (*expr_p))
&& is_gimple_min_invariant (cached_lhs)))
retval = true;
+
+ if (modify_expr_p
+ && !tree_ssa_useless_type_conversion_1 (TREE_TYPE (*expr_p),
+ TREE_TYPE (cached_lhs)))
+ cached_lhs = fold_convert (TREE_TYPE (*expr_p), cached_lhs);
propagate_tree_value (expr_p, cached_lhs);
mark_stmt_modified (stmt);
@@ -3088,11 +3103,8 @@ lookup_avail_expr (tree stmt, bool insert)
{
tree t = element->rhs;
free (element);
-
- if (TREE_CODE (t) == EQ_EXPR)
- return boolean_false_node;
- else
- return boolean_true_node;
+ return constant_boolean_node (TREE_CODE (t) != EQ_EXPR,
+ TREE_TYPE (element->rhs));
}
}