From 68b9f53b865b6b0afdafa8f24ca83ec9c94bb780 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 10 Aug 2004 18:31:26 +0000 Subject: [PATCH] tree-cfg.c (bsi_insert_before, [...]): Call modify_stmt after linking stmt into the program. 2004-08-10 Andrew MacLeod * tree-cfg.c (bsi_insert_before, bsi_insert_after): Call modify_stmt after linking stmt into the program. (bsi_remove): Don't call modify_stmt. * tree-complex.c (update_complex_assignment, expand_complex_comparison): Call modify_stmt after changing the stmt. * tree-outof-ssa.c (rewrite_trees): Call modify_stmt only if not removing the stmt. * tree-ssa-ccp.c (substitute_and_fold): Call modify_stmt after changing the stmt, and only if needed. * tree-ssa-dom.c (thread_across_edge): Pass no annotation for a dummy expression. (simplify_rhs_and_lookup_avail_expr): Don't take an annotation param. (simplify_cond_and_lookup_avail_expr): Use modify_stmt. (simplify_switch_and_lookup_avail_expr): Don't take an annotation param. (eliminate_redundant_computations): Don't pass an annotation. Call modify_stmt rather than setting the annotation directly. (record_equivalences_from_stmt): Remove unused local 'j'. (cprop_operand): Take a stmt rather than an annotation as a parameter. Call modify_stmt. (cprop_into_stmt): Pass stmt rather than annotation. (update_rhs_and_lookup_avail_expr): Call modify_stmt. * tree-ssa-loop-im.c (schedule_sm): Call get_stmt_ann rather than modify_stmt. * tree-ssa.c (propagate_into_addr): Dont call modify_stmt. From-SVN: r85765 --- gcc/ChangeLog | 27 +++++++++++++++++++++ gcc/tree-cfg.c | 5 ++-- gcc/tree-complex.c | 15 ++++++------ gcc/tree-outof-ssa.c | 2 +- gcc/tree-ssa-ccp.c | 3 ++- gcc/tree-ssa-dom.c | 53 ++++++++++++++++++------------------------ gcc/tree-ssa-loop-im.c | 3 +-- gcc/tree-ssa.c | 2 +- 8 files changed, 64 insertions(+), 46 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fc95cf250c5..e8d1398d3f8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,30 @@ +2004-08-10 Andrew MacLeod + + * tree-cfg.c (bsi_insert_before, bsi_insert_after): Call modify_stmt + after linking stmt into the program. + (bsi_remove): Don't call modify_stmt. + * tree-complex.c (update_complex_assignment, + expand_complex_comparison): Call modify_stmt after changing the stmt. + * tree-outof-ssa.c (rewrite_trees): Call modify_stmt only if not + removing the stmt. + * tree-ssa-ccp.c (substitute_and_fold): Call modify_stmt after changing + the stmt, and only if needed. + * tree-ssa-dom.c (thread_across_edge): Pass no annotation for a dummy + expression. + (simplify_rhs_and_lookup_avail_expr): Don't take an annotation param. + (simplify_cond_and_lookup_avail_expr): Use modify_stmt. + (simplify_switch_and_lookup_avail_expr): Don't take an annotation param. + (eliminate_redundant_computations): Don't pass an annotation. Call + modify_stmt rather than setting the annotation directly. + (record_equivalences_from_stmt): Remove unused local 'j'. + (cprop_operand): Take a stmt rather than an annotation as a parameter. + Call modify_stmt. + (cprop_into_stmt): Pass stmt rather than annotation. + (update_rhs_and_lookup_avail_expr): Call modify_stmt. + * tree-ssa-loop-im.c (schedule_sm): Call get_stmt_ann rather than + modify_stmt. + * tree-ssa.c (propagate_into_addr): Dont call modify_stmt. + 2004-08-10 Jason Merrill PR middle-end/16948 diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index c9bc37ce6b9..33c8325041b 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2814,8 +2814,8 @@ void bsi_insert_before (block_stmt_iterator *i, tree t, enum bsi_iterator_update m) { set_bb_for_stmt (t, i->bb); - modify_stmt (t); tsi_link_before (&i->tsi, t, m); + modify_stmt (t); } @@ -2827,8 +2827,8 @@ void bsi_insert_after (block_stmt_iterator *i, tree t, enum bsi_iterator_update m) { set_bb_for_stmt (t, i->bb); - modify_stmt (t); tsi_link_after (&i->tsi, t, m); + modify_stmt (t); } @@ -2840,7 +2840,6 @@ bsi_remove (block_stmt_iterator *i) { tree t = bsi_stmt (*i); set_bb_for_stmt (t, NULL); - modify_stmt (t); tsi_delink (&i->tsi); } diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c index a960f92c424..54ea8197df1 100644 --- a/gcc/tree-complex.c +++ b/gcc/tree-complex.c @@ -78,12 +78,12 @@ update_complex_assignment (block_stmt_iterator *bsi, tree r, tree i) tree stmt = bsi_stmt (*bsi); tree type; - modify_stmt (stmt); if (TREE_CODE (stmt) == RETURN_EXPR) stmt = TREE_OPERAND (stmt, 0); type = TREE_TYPE (TREE_OPERAND (stmt, 1)); TREE_OPERAND (stmt, 1) = build (COMPLEX_EXPR, type, r, i); + modify_stmt (stmt); } /* Expand complex addition to scalars: @@ -326,7 +326,7 @@ static void expand_complex_comparison (block_stmt_iterator *bsi, tree ar, tree ai, tree br, tree bi, enum tree_code code) { - tree cr, ci, cc, stmt, type; + tree cr, ci, cc, stmt, expr, type; cr = gimplify_build2 (bsi, code, boolean_type_node, ar, br); ci = gimplify_build2 (bsi, code, boolean_type_node, ai, bi); @@ -334,17 +334,16 @@ expand_complex_comparison (block_stmt_iterator *bsi, tree ar, tree ai, (code == EQ_EXPR ? TRUTH_AND_EXPR : TRUTH_OR_EXPR), boolean_type_node, cr, ci); - stmt = bsi_stmt (*bsi); - modify_stmt (stmt); + stmt = expr = bsi_stmt (*bsi); switch (TREE_CODE (stmt)) { case RETURN_EXPR: - stmt = TREE_OPERAND (stmt, 0); + expr = TREE_OPERAND (stmt, 0); /* FALLTHRU */ case MODIFY_EXPR: - type = TREE_TYPE (TREE_OPERAND (stmt, 1)); - TREE_OPERAND (stmt, 1) = fold_convert (type, cc); + type = TREE_TYPE (TREE_OPERAND (expr, 1)); + TREE_OPERAND (expr, 1) = fold_convert (type, cc); break; case COND_EXPR: TREE_OPERAND (stmt, 0) = cc; @@ -352,6 +351,8 @@ expand_complex_comparison (block_stmt_iterator *bsi, tree ar, tree ai, default: abort (); } + + modify_stmt (stmt); } /* Process one statement. If we identify a complex operation, expand it. */ diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c index 33a927e14ae..5b1e2a8fc1e 100644 --- a/gcc/tree-outof-ssa.c +++ b/gcc/tree-outof-ssa.c @@ -1935,7 +1935,7 @@ rewrite_trees (var_map map, tree *values) && (DEF_FROM_PTR (def_p) == USE_OP (uses, 0))) remove = 1; } - if (changed) + if (changed & !remove) modify_stmt (stmt); } diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index f883e373cc4..e2d3bbf180a 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -427,7 +427,6 @@ substitute_and_fold (void) { bool changed = fold_stmt (bsi_stmt_ptr (i)); stmt = bsi_stmt(i); - modify_stmt (stmt); /* If we folded a builtin function, we'll likely need to rename VDEFs. */ if (replaced_address || changed) @@ -436,6 +435,8 @@ substitute_and_fold (void) if (maybe_clean_eh_stmt (stmt)) tree_purge_dead_eh_edges (bb); } + else + modify_stmt (stmt); } if (dump_file && (dump_flags & TDF_DETAILS)) diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 26df9ed7591..c089cf1b590 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -223,14 +223,12 @@ static void record_cond (tree, tree, varray_type *); static void record_dominating_conditions (tree, varray_type *); static void record_const_or_copy (tree, tree, varray_type *); static void record_equality (tree, tree, varray_type *); -static tree update_rhs_and_lookup_avail_expr (tree, tree, varray_type *, - stmt_ann_t, bool); +static tree update_rhs_and_lookup_avail_expr (tree, tree, varray_type *, bool); static tree simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *, - tree, stmt_ann_t, int); + tree, int); static tree simplify_cond_and_lookup_avail_expr (tree, varray_type *, stmt_ann_t, int); -static tree simplify_switch_and_lookup_avail_expr (tree, varray_type *, - stmt_ann_t, int); +static tree simplify_switch_and_lookup_avail_expr (tree, varray_type *, int); static tree find_equivalent_equality_comparison (tree); static void record_range (tree, basic_block, varray_type *); static bool extract_range_from_cond (tree, tree *, tree *, int *); @@ -652,10 +650,9 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e) cached_lhs = lookup_avail_expr (dummy_cond, NULL, false); if (!cached_lhs || ! is_gimple_min_invariant (cached_lhs)) { - stmt_ann_t ann = get_stmt_ann (dummy_cond); cached_lhs = simplify_cond_and_lookup_avail_expr (dummy_cond, NULL, - ann, + NULL, false); } } @@ -1628,9 +1625,7 @@ record_equality (tree x, tree y, varray_type *block_const_and_copies_p) static tree simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data, - tree stmt, - stmt_ann_t ann, - int insert) + tree stmt, int insert) { tree rhs = TREE_OPERAND (stmt, 1); enum tree_code rhs_code = TREE_CODE (rhs); @@ -1663,7 +1658,6 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data, result = update_rhs_and_lookup_avail_expr (stmt, rhs_def_operand, &bd->avail_exprs, - ann, insert); } } @@ -1748,7 +1742,7 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data, && TREE_CODE (TREE_OPERAND (t, 0)) == SSA_NAME && is_gimple_val (TREE_OPERAND (t, 1)))) result = update_rhs_and_lookup_avail_expr - (stmt, t, &bd->avail_exprs, ann, insert); + (stmt, t, &bd->avail_exprs, insert); } } } @@ -1808,8 +1802,7 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data, op1, integer_one_node))); result = update_rhs_and_lookup_avail_expr (stmt, t, - &bd->avail_exprs, - ann, insert); + &bd->avail_exprs, insert); } } @@ -1880,8 +1873,7 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data, t = op; result = update_rhs_and_lookup_avail_expr (stmt, t, - &bd->avail_exprs, - ann, insert); + &bd->avail_exprs, insert); } } @@ -1893,8 +1885,7 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data, if (t) result = update_rhs_and_lookup_avail_expr (stmt, t, - &bd->avail_exprs, - ann, insert); + &bd->avail_exprs, insert); } return result; @@ -2001,7 +1992,11 @@ simplify_cond_and_lookup_avail_expr (tree stmt, /* Update the statement to use the new equivalent condition. */ COND_EXPR_COND (stmt) = new_cond; - ann->modified = 1; + + /* If this is not a real stmt, ann will be NULL and we + avoid processing the operands. */ + if (ann) + modify_stmt (stmt); /* Lookup the condition and return its known value if it exists. */ @@ -2197,7 +2192,6 @@ simplify_cond_and_lookup_avail_expr (tree stmt, static tree simplify_switch_and_lookup_avail_expr (tree stmt, varray_type *block_avail_exprs_p, - stmt_ann_t ann, int insert) { tree cond = SWITCH_COND (stmt); @@ -2243,7 +2237,7 @@ simplify_switch_and_lookup_avail_expr (tree stmt, if (!fail) { SWITCH_COND (stmt) = def; - ann->modified = 1; + modify_stmt (stmt); return lookup_avail_expr (stmt, block_avail_exprs_p, insert); } @@ -2404,7 +2398,6 @@ eliminate_redundant_computations (struct dom_walk_data *walk_data, if (! cached_lhs && TREE_CODE (stmt) == MODIFY_EXPR) cached_lhs = simplify_rhs_and_lookup_avail_expr (walk_data, stmt, - ann, insert); /* Similarly if this is a COND_EXPR and we did not find its expression in the hash table, simplify the condition and @@ -2418,7 +2411,6 @@ eliminate_redundant_computations (struct dom_walk_data *walk_data, else if (!cached_lhs && TREE_CODE (stmt) == SWITCH_EXPR) cached_lhs = simplify_switch_and_lookup_avail_expr (stmt, &bd->avail_exprs, - ann, insert); opt_stats.num_exprs_considered++; @@ -2465,7 +2457,7 @@ eliminate_redundant_computations (struct dom_walk_data *walk_data, retval = true; propagate_tree_value (expr_p, cached_lhs); - ann->modified = 1; + modify_stmt (stmt); } return retval; } @@ -2642,7 +2634,7 @@ record_equivalences_from_stmt (tree stmt, CONST_AND_COPIES. */ static bool -cprop_operand (stmt_ann_t ann, use_operand_p op_p, varray_type const_and_copies) +cprop_operand (tree stmt, use_operand_p op_p, varray_type const_and_copies) { bool may_have_exposed_new_symbols = false; tree val; @@ -2721,7 +2713,7 @@ cprop_operand (stmt_ann_t ann, use_operand_p op_p, varray_type const_and_copies) /* And note that we modified this statement. This is now safe, even if we changed virtual operands since we will rescan the statement and rewrite its operands again. */ - ann->modified = 1; + modify_stmt (stmt); } return may_have_exposed_new_symbols; } @@ -2749,7 +2741,7 @@ cprop_into_stmt (tree stmt, varray_type const_and_copies) use_operand_p op_p = USE_OP_PTR (uses, i); if (TREE_CODE (USE_FROM_PTR (op_p)) == SSA_NAME) may_have_exposed_new_symbols - |= cprop_operand (ann, op_p, const_and_copies); + |= cprop_operand (stmt, op_p, const_and_copies); } vuses = VUSE_OPS (ann); @@ -2759,7 +2751,7 @@ cprop_into_stmt (tree stmt, varray_type const_and_copies) use_operand_p op_p = VUSE_OP_PTR (vuses, i); if (TREE_CODE (USE_FROM_PTR (op_p)) == SSA_NAME) may_have_exposed_new_symbols - |= cprop_operand (ann, op_p, const_and_copies); + |= cprop_operand (stmt, op_p, const_and_copies); } v_may_defs = V_MAY_DEF_OPS (ann); @@ -2769,7 +2761,7 @@ cprop_into_stmt (tree stmt, varray_type const_and_copies) use_operand_p op_p = V_MAY_DEF_OP_PTR (v_may_defs, i); if (TREE_CODE (USE_FROM_PTR (op_p)) == SSA_NAME) may_have_exposed_new_symbols - |= cprop_operand (ann, op_p, const_and_copies); + |= cprop_operand (stmt, op_p, const_and_copies); } return may_have_exposed_new_symbols; } @@ -2936,7 +2928,6 @@ optimize_stmt (struct dom_walk_data *walk_data, basic_block bb, static tree update_rhs_and_lookup_avail_expr (tree stmt, tree new_rhs, varray_type *block_avail_exprs_p, - stmt_ann_t ann, bool insert) { tree cached_lhs = NULL; @@ -2982,7 +2973,7 @@ update_rhs_and_lookup_avail_expr (tree stmt, tree new_rhs, /* And make sure we record the fact that we modified this statement. */ - ann->modified = 1; + modify_stmt (stmt); return cached_lhs; } diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index 465442615cb..3d2d1c6a7a9 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -1007,8 +1007,7 @@ schedule_sm (struct loop *loop, edge *exits, unsigned n_exits, tree ref, /* Emit the load & stores. */ load = build (MODIFY_EXPR, void_type_node, tmp_var, ref); - modify_stmt (load); - stmt_ann (load)->common.aux = xcalloc (1, sizeof (struct lim_aux_data)); + get_stmt_ann (load)->common.aux = xcalloc (1, sizeof (struct lim_aux_data)); LIM_DATA (load)->max_loop = loop; LIM_DATA (load)->tgt_loop = loop; diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index dd79b5a7d9f..eb6f9676617 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -925,7 +925,6 @@ propagate_into_addr (tree stmt, tree var, tree *x, tree repl) || TREE_OPERAND (*x, 0) != var) return; - modify_stmt (stmt); if (TREE_TYPE (*x) == TREE_TYPE (addr_var)) { *x = addr_var; @@ -933,6 +932,7 @@ propagate_into_addr (tree stmt, tree var, tree *x, tree repl) return; } + /* Frontends sometimes produce expressions like *&a instead of a[0]. Create a temporary variable to handle this case. */ ass_stmt = build2 (MODIFY_EXPR, void_type_node, NULL_TREE, repl); -- 2.30.2