From d829c408d24409897d2444faed69ed072c0d73fe Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Tue, 6 Dec 2011 09:02:17 +0000 Subject: [PATCH] re PR tree-optimization/51363 (ICE: in gimple_rhs_has_side_effects, at gimple.c:2530 with -O -fno-tree-ccp) 2011-12-06 Richard Guenther PR tree-optimization/51363 * gimple.c (gimple_rhs_has_side_effects): Remove. * gimple.h (gimple_rhs_has_side_effects): Likewise. * tree-ssa-dom.c (optimize_stmt): Simplify conditional. From-SVN: r182041 --- gcc/ChangeLog | 7 ++++++ gcc/gimple.c | 63 ---------------------------------------------- gcc/gimple.h | 1 - gcc/tree-ssa-dom.c | 8 +++--- 4 files changed, 10 insertions(+), 69 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 18ad86a1463..e27962f03d5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-12-06 Richard Guenther + + PR tree-optimization/51363 + * gimple.c (gimple_rhs_has_side_effects): Remove. + * gimple.h (gimple_rhs_has_side_effects): Likewise. + * tree-ssa-dom.c (optimize_stmt): Simplify conditional. + 2011-12-06 Alan Modra PR target/50906 diff --git a/gcc/gimple.c b/gcc/gimple.c index c72b39a0d64..81c119048f2 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -2484,69 +2484,6 @@ gimple_has_side_effects (const_gimple s) return false; } -/* Return true if the RHS of statement S has side effects. - We may use it to determine if it is admissable to replace - an assignment or call with a copy of a previously-computed - value. In such cases, side-effects due to the LHS are - preserved. */ - -bool -gimple_rhs_has_side_effects (const_gimple s) -{ - unsigned i; - - if (is_gimple_call (s)) - { - unsigned nargs = gimple_call_num_args (s); - tree fn; - - if (!(gimple_call_flags (s) & (ECF_CONST | ECF_PURE))) - return true; - - /* We cannot use gimple_has_volatile_ops here, - because we must ignore a volatile LHS. */ - fn = gimple_call_fn (s); - if (fn && (TREE_SIDE_EFFECTS (fn) || TREE_THIS_VOLATILE (fn))) - { - gcc_assert (gimple_has_volatile_ops (s)); - return true; - } - - for (i = 0; i < nargs; i++) - if (TREE_SIDE_EFFECTS (gimple_call_arg (s, i)) - || TREE_THIS_VOLATILE (gimple_call_arg (s, i))) - return true; - - return false; - } - else if (is_gimple_assign (s)) - { - /* Skip the first operand, the LHS. */ - for (i = 1; i < gimple_num_ops (s); i++) - if (TREE_SIDE_EFFECTS (gimple_op (s, i)) - || TREE_THIS_VOLATILE (gimple_op (s, i))) - { - gcc_assert (gimple_has_volatile_ops (s)); - return true; - } - } - else if (is_gimple_debug (s)) - return false; - else - { - /* For statements without an LHS, examine all arguments. */ - for (i = 0; i < gimple_num_ops (s); i++) - if (TREE_SIDE_EFFECTS (gimple_op (s, i)) - || TREE_THIS_VOLATILE (gimple_op (s, i))) - { - gcc_assert (gimple_has_volatile_ops (s)); - return true; - } - } - - return false; -} - /* Helper for gimple_could_trap_p and gimple_assign_rhs_could_trap_p. Return true if S can trap. When INCLUDE_MEM is true, check whether the memory operations could trap. When INCLUDE_STORES is true and diff --git a/gcc/gimple.h b/gcc/gimple.h index ec4e76e13dd..487b516cbd3 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -948,7 +948,6 @@ void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *); gimple gimple_build_cond_from_tree (tree, tree, tree); void gimple_cond_set_condition_from_tree (gimple, tree); bool gimple_has_side_effects (const_gimple); -bool gimple_rhs_has_side_effects (const_gimple); bool gimple_could_trap_p (gimple); bool gimple_could_trap_p_1 (gimple, bool, bool); bool gimple_assign_rhs_could_trap_p (gimple); diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 949acf1d168..f8207e078e4 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -2154,12 +2154,10 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si) /* Check for redundant computations. Do this optimization only for assignments that have no volatile ops and conditionals. */ - may_optimize_p = (!gimple_has_volatile_ops (stmt) - && ((is_gimple_assign (stmt) - && !gimple_rhs_has_side_effects (stmt)) + may_optimize_p = (!gimple_has_side_effects (stmt) + && (is_gimple_assign (stmt) || (is_gimple_call (stmt) - && gimple_call_lhs (stmt) != NULL_TREE - && !gimple_rhs_has_side_effects (stmt)) + && gimple_call_lhs (stmt) != NULL_TREE) || gimple_code (stmt) == GIMPLE_COND || gimple_code (stmt) == GIMPLE_SWITCH)); -- 2.30.2