Commit 7af1c0ad by Richard Biener Committed by Richard Biener

tree-ssa-sccvn.h (has_VN_INFO): Declare.

2017-05-12  Richard Biener  <rguenther@suse.de>

	* tree-ssa-sccvn.h (has_VN_INFO): Declare.
	* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
	Fold all stmts not inplace.

	* g++.dg/tree-ssa/ssa-dse-2.C: Adjust.

From-SVN: r247966
parent f7e95bdb
2017-05-12 Richard Biener <rguenther@suse.de> 2017-05-12 Richard Biener <rguenther@suse.de>
* tree-ssa-sccvn.h (has_VN_INFO): Declare.
* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
Fold all stmts not inplace.
2017-05-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/80713 PR tree-optimization/80713
* tree-ssa-pre.c (remove_dead_inserted_code): Clear * tree-ssa-pre.c (remove_dead_inserted_code): Clear
inserted_exprs bit for not removed stmts. inserted_exprs bit for not removed stmts.
......
2017-05-12 Richard Biener <rguenther@suse.de>
* g++.dg/tree-ssa/ssa-dse-2.C: Adjust.
2017-05-12 Paolo Carlini <paolo.carlini@oracle.com> 2017-05-12 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/67687 PR c++/67687
......
...@@ -54,6 +54,4 @@ fill_vec_av_set (av_set_t av) ...@@ -54,6 +54,4 @@ fill_vec_av_set (av_set_t av)
} }
/* { dg-final { scan-tree-dump-not "Trimming statement .head = -" "dse2" } } */ /* { dg-final { scan-tree-dump-not "Trimming statement .head = -" "dse2" } } */
/* { dg-final { scan-tree-dump "Deleted dead call: " "dse2" } } */ /* { dg-final { scan-tree-dump-not "mem\[^\r\n\]*, 0\\);" "dse2" } } */
...@@ -4645,30 +4645,51 @@ eliminate_dom_walker::before_dom_children (basic_block b) ...@@ -4645,30 +4645,51 @@ eliminate_dom_walker::before_dom_children (basic_block b)
&& TREE_CODE (gimple_assign_rhs1 (stmt)) == ADDR_EXPR) && TREE_CODE (gimple_assign_rhs1 (stmt)) == ADDR_EXPR)
recompute_tree_invariant_for_addr_expr (gimple_assign_rhs1 (stmt)); recompute_tree_invariant_for_addr_expr (gimple_assign_rhs1 (stmt));
gimple *old_stmt = stmt; gimple *old_stmt = stmt;
if (is_gimple_call (stmt)) gimple_stmt_iterator prev = gsi;
gsi_prev (&prev);
if (fold_stmt (&gsi))
{ {
/* ??? Only fold calls inplace for now, this may create new /* fold_stmt may have created new stmts inbetween
SSA names which in turn will confuse free_scc_vn SSA name the previous stmt and the folded stmt. Mark
release code. */ all defs created there as varying to not confuse
fold_stmt_inplace (&gsi); the SCCVN machinery as we're using that even during
/* When changing a call into a noreturn call, cfg cleanup elimination. */
is needed to fix up the noreturn call. */ if (gsi_end_p (prev))
if (!was_noreturn && gimple_call_noreturn_p (stmt)) prev = gsi_start_bb (b);
el_to_fixup.safe_push (stmt); else
} gsi_next (&prev);
else if (gsi_stmt (prev) != gsi_stmt (gsi))
{ do
fold_stmt (&gsi); {
stmt = gsi_stmt (gsi); tree def;
if ((gimple_code (stmt) == GIMPLE_COND ssa_op_iter dit;
&& (gimple_cond_true_p (as_a <gcond *> (stmt)) FOR_EACH_SSA_TREE_OPERAND (def, gsi_stmt (prev),
|| gimple_cond_false_p (as_a <gcond *> (stmt)))) dit, SSA_OP_ALL_DEFS)
|| (gimple_code (stmt) == GIMPLE_SWITCH /* As existing DEFs may move between stmts
&& TREE_CODE (gimple_switch_index ( we have to guard VN_INFO_GET. */
as_a <gswitch *> (stmt))) if (! has_VN_INFO (def))
== INTEGER_CST)) VN_INFO_GET (def)->valnum = def;
el_todo |= TODO_cleanup_cfg; if (gsi_stmt (prev) == gsi_stmt (gsi))
break;
gsi_next (&prev);
}
while (1);
} }
stmt = gsi_stmt (gsi);
/* When changing a call into a noreturn call, cfg cleanup
is needed to fix up the noreturn call. */
if (!was_noreturn
&& is_gimple_call (stmt) && gimple_call_noreturn_p (stmt))
el_to_fixup.safe_push (stmt);
/* When changing a condition or switch into one we know what
edge will be executed, schedule a cfg cleanup. */
if ((gimple_code (stmt) == GIMPLE_COND
&& (gimple_cond_true_p (as_a <gcond *> (stmt))
|| gimple_cond_false_p (as_a <gcond *> (stmt))))
|| (gimple_code (stmt) == GIMPLE_SWITCH
&& TREE_CODE (gimple_switch_index
(as_a <gswitch *> (stmt))) == INTEGER_CST))
el_todo |= TODO_cleanup_cfg;
/* If we removed EH side-effects from the statement, clean /* If we removed EH side-effects from the statement, clean
its EH information. */ its EH information. */
if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt)) if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt))
......
...@@ -209,6 +209,7 @@ typedef struct vn_ssa_aux ...@@ -209,6 +209,7 @@ typedef struct vn_ssa_aux
enum vn_lookup_kind { VN_NOWALK, VN_WALK, VN_WALKREWRITE }; enum vn_lookup_kind { VN_NOWALK, VN_WALK, VN_WALKREWRITE };
/* Return the value numbering info for an SSA_NAME. */ /* Return the value numbering info for an SSA_NAME. */
bool has_VN_INFO (tree);
extern vn_ssa_aux_t VN_INFO (tree); extern vn_ssa_aux_t VN_INFO (tree);
extern vn_ssa_aux_t VN_INFO_GET (tree); extern vn_ssa_aux_t VN_INFO_GET (tree);
tree vn_get_expr_for (tree); tree vn_get_expr_for (tree);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment