Commit 24c40f9a by Richard Biener Committed by Richard Biener

tree-ssa-sccvn.h (run_scc_vn): Adjust prototype.

2017-04-24  Richard Biener  <rguenther@suse.de>

	* tree-ssa-sccvn.h (run_scc_vn): Adjust prototype.
	* tree-ssa-sccvn.c (print_scc): Print SCC size.
	(extract_and_process_scc_for_name): Never fail but drop SCC to varying.
	(DFS): Adjust and never fail.
	(sccvn_dom_walker::fail): Remove.
	(sccvn_dom_walker::before_dom_children): Adjust.
	(run_scc_vn): Likewise and never fail.
	* tree-ssa-pre.c (pass_pre::execute): Adjust.
	(pass_fre::execute): Likewise.

From-SVN: r247092
parent 4c7c437c
2017-04-24 Richard Biener <rguenther@suse.de> 2017-04-24 Richard Biener <rguenther@suse.de>
* tree-ssa-sccvn.h (run_scc_vn): Adjust prototype.
* tree-ssa-sccvn.c (print_scc): Print SCC size.
(extract_and_process_scc_for_name): Never fail but drop SCC to varying.
(DFS): Adjust and never fail.
(sccvn_dom_walker::fail): Remove.
(sccvn_dom_walker::before_dom_children): Adjust.
(run_scc_vn): Likewise and never fail.
* tree-ssa-pre.c (pass_pre::execute): Adjust.
(pass_fre::execute): Likewise.
2017-04-24 Richard Biener <rguenther@suse.de>
PR tree-optimization/79725 PR tree-optimization/79725
* tree-ssa-sink.c (statement_sink_location): Return whether * tree-ssa-sink.c (statement_sink_location): Return whether
failure reason was zero uses. Move that check later. failure reason was zero uses. Move that check later.
......
...@@ -5086,11 +5086,7 @@ pass_pre::execute (function *fun) ...@@ -5086,11 +5086,7 @@ pass_pre::execute (function *fun)
loop_optimizer_init may create new phis, etc. */ loop_optimizer_init may create new phis, etc. */
loop_optimizer_init (LOOPS_NORMAL); loop_optimizer_init (LOOPS_NORMAL);
if (!run_scc_vn (VN_WALK)) run_scc_vn (VN_WALK);
{
loop_optimizer_finalize ();
return 0;
}
init_pre (); init_pre ();
scev_initialize (); scev_initialize ();
...@@ -5202,8 +5198,7 @@ pass_fre::execute (function *fun) ...@@ -5202,8 +5198,7 @@ pass_fre::execute (function *fun)
{ {
unsigned int todo = 0; unsigned int todo = 0;
if (!run_scc_vn (VN_WALKREWRITE)) run_scc_vn (VN_WALKREWRITE);
return 0;
memset (&pre_stats, 0, sizeof (pre_stats)); memset (&pre_stats, 0, sizeof (pre_stats));
......
...@@ -3153,7 +3153,7 @@ print_scc (FILE *out, vec<tree> scc) ...@@ -3153,7 +3153,7 @@ print_scc (FILE *out, vec<tree> scc)
tree var; tree var;
unsigned int i; unsigned int i;
fprintf (out, "SCC consists of:"); fprintf (out, "SCC consists of %u:", scc.length ());
FOR_EACH_VEC_ELT (scc, i, var) FOR_EACH_VEC_ELT (scc, i, var)
{ {
fprintf (out, " "); fprintf (out, " ");
...@@ -4316,7 +4316,7 @@ process_scc (vec<tree> scc) ...@@ -4316,7 +4316,7 @@ process_scc (vec<tree> scc)
and process them. Returns true if all went well, false if and process them. Returns true if all went well, false if
we run into resource limits. */ we run into resource limits. */
static bool static void
extract_and_process_scc_for_name (tree name) extract_and_process_scc_for_name (tree name)
{ {
auto_vec<tree> scc; auto_vec<tree> scc;
...@@ -4332,24 +4332,37 @@ extract_and_process_scc_for_name (tree name) ...@@ -4332,24 +4332,37 @@ extract_and_process_scc_for_name (tree name)
scc.safe_push (x); scc.safe_push (x);
} while (x != name); } while (x != name);
/* Bail out of SCCVN in case a SCC turns out to be incredibly large. */ /* Drop all defs in the SCC to varying in case a SCC turns out to be
if (scc.length () incredibly large.
> (unsigned)PARAM_VALUE (PARAM_SCCVN_MAX_SCC_SIZE)) ??? Just switch to a non-optimistic mode that avoids any iteration. */
if (scc.length () > (unsigned)PARAM_VALUE (PARAM_SCCVN_MAX_SCC_SIZE))
{ {
if (dump_file) if (dump_file)
fprintf (dump_file, "WARNING: Giving up with SCCVN due to " {
"SCC size %u exceeding %u\n", scc.length (), print_scc (dump_file, scc);
(unsigned)PARAM_VALUE (PARAM_SCCVN_MAX_SCC_SIZE)); fprintf (dump_file, "WARNING: Giving up value-numbering SCC due to "
"size %u exceeding %u\n", scc.length (),
return false; (unsigned)PARAM_VALUE (PARAM_SCCVN_MAX_SCC_SIZE));
}
tree var;
unsigned i;
FOR_EACH_VEC_ELT (scc, i, var)
{
gimple *def = SSA_NAME_DEF_STMT (var);
mark_use_processed (var);
if (SSA_NAME_IS_DEFAULT_DEF (var)
|| gimple_code (def) == GIMPLE_PHI)
set_ssa_val_to (var, var);
else
defs_to_varying (def);
}
return;
} }
if (scc.length () > 1) if (scc.length () > 1)
sort_scc (scc); sort_scc (scc);
process_scc (scc); process_scc (scc);
return true;
} }
/* Depth first search on NAME to discover and process SCC's in the SSA /* Depth first search on NAME to discover and process SCC's in the SSA
...@@ -4359,7 +4372,7 @@ extract_and_process_scc_for_name (tree name) ...@@ -4359,7 +4372,7 @@ extract_and_process_scc_for_name (tree name)
Returns true if successful, false if we stopped processing SCC's due Returns true if successful, false if we stopped processing SCC's due
to resource constraints. */ to resource constraints. */
static bool static void
DFS (tree name) DFS (tree name)
{ {
auto_vec<ssa_op_iter> itervec; auto_vec<ssa_op_iter> itervec;
...@@ -4399,12 +4412,11 @@ start_over: ...@@ -4399,12 +4412,11 @@ start_over:
{ {
/* See if we found an SCC. */ /* See if we found an SCC. */
if (VN_INFO (name)->low == VN_INFO (name)->dfsnum) if (VN_INFO (name)->low == VN_INFO (name)->dfsnum)
if (!extract_and_process_scc_for_name (name)) extract_and_process_scc_for_name (name);
return false;
/* Check if we are done. */ /* Check if we are done. */
if (namevec.is_empty ()) if (namevec.is_empty ())
return true; return;
/* Restore the last use walker and continue walking there. */ /* Restore the last use walker and continue walking there. */
use = name; use = name;
...@@ -4687,7 +4699,7 @@ class sccvn_dom_walker : public dom_walker ...@@ -4687,7 +4699,7 @@ class sccvn_dom_walker : public dom_walker
{ {
public: public:
sccvn_dom_walker () sccvn_dom_walker ()
: dom_walker (CDI_DOMINATORS, true), fail (false), cond_stack (0) {} : dom_walker (CDI_DOMINATORS, true), cond_stack (0) {}
virtual edge before_dom_children (basic_block); virtual edge before_dom_children (basic_block);
virtual void after_dom_children (basic_block); virtual void after_dom_children (basic_block);
...@@ -4697,7 +4709,6 @@ public: ...@@ -4697,7 +4709,6 @@ public:
void record_conds (basic_block, void record_conds (basic_block,
enum tree_code code, tree lhs, tree rhs, bool value); enum tree_code code, tree lhs, tree rhs, bool value);
bool fail;
auto_vec<std::pair <basic_block, std::pair <vn_nary_op_t, vn_nary_op_t> > > auto_vec<std::pair <basic_block, std::pair <vn_nary_op_t, vn_nary_op_t> > >
cond_stack; cond_stack;
}; };
...@@ -4793,9 +4804,6 @@ sccvn_dom_walker::before_dom_children (basic_block bb) ...@@ -4793,9 +4804,6 @@ sccvn_dom_walker::before_dom_children (basic_block bb)
edge e; edge e;
edge_iterator ei; edge_iterator ei;
if (fail)
return NULL;
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Visiting BB %d\n", bb->index); fprintf (dump_file, "Visiting BB %d\n", bb->index);
...@@ -4851,12 +4859,8 @@ sccvn_dom_walker::before_dom_children (basic_block bb) ...@@ -4851,12 +4859,8 @@ sccvn_dom_walker::before_dom_children (basic_block bb)
{ {
gphi *phi = gsi.phi (); gphi *phi = gsi.phi ();
tree res = PHI_RESULT (phi); tree res = PHI_RESULT (phi);
if (!VN_INFO (res)->visited if (!VN_INFO (res)->visited)
&& !DFS (res)) DFS (res);
{
fail = true;
return NULL;
}
} }
for (gimple_stmt_iterator gsi = gsi_start_bb (bb); for (gimple_stmt_iterator gsi = gsi_start_bb (bb);
!gsi_end_p (gsi); gsi_next (&gsi)) !gsi_end_p (gsi); gsi_next (&gsi))
...@@ -4864,12 +4868,8 @@ sccvn_dom_walker::before_dom_children (basic_block bb) ...@@ -4864,12 +4868,8 @@ sccvn_dom_walker::before_dom_children (basic_block bb)
ssa_op_iter i; ssa_op_iter i;
tree op; tree op;
FOR_EACH_SSA_TREE_OPERAND (op, gsi_stmt (gsi), i, SSA_OP_ALL_DEFS) FOR_EACH_SSA_TREE_OPERAND (op, gsi_stmt (gsi), i, SSA_OP_ALL_DEFS)
if (!VN_INFO (op)->visited if (!VN_INFO (op)->visited)
&& !DFS (op)) DFS (op);
{
fail = true;
return NULL;
}
} }
/* Finally look at the last stmt. */ /* Finally look at the last stmt. */
...@@ -4941,7 +4941,7 @@ sccvn_dom_walker::before_dom_children (basic_block bb) ...@@ -4941,7 +4941,7 @@ sccvn_dom_walker::before_dom_children (basic_block bb)
due to resource constraints. DEFAULT_VN_WALK_KIND_ specifies due to resource constraints. DEFAULT_VN_WALK_KIND_ specifies
how we use the alias oracle walking during the VN process. */ how we use the alias oracle walking during the VN process. */
bool void
run_scc_vn (vn_lookup_kind default_vn_walk_kind_) run_scc_vn (vn_lookup_kind default_vn_walk_kind_)
{ {
size_t i; size_t i;
...@@ -4977,12 +4977,6 @@ run_scc_vn (vn_lookup_kind default_vn_walk_kind_) ...@@ -4977,12 +4977,6 @@ run_scc_vn (vn_lookup_kind default_vn_walk_kind_)
SSA defs and decide whether outgoing edges are not executable. */ SSA defs and decide whether outgoing edges are not executable. */
sccvn_dom_walker walker; sccvn_dom_walker walker;
walker.walk (ENTRY_BLOCK_PTR_FOR_FN (cfun)); walker.walk (ENTRY_BLOCK_PTR_FOR_FN (cfun));
if (walker.fail)
{
scc_vn_restore_ssa_info ();
free_scc_vn ();
return false;
}
/* Initialize the value ids and prune out remaining VN_TOPs /* Initialize the value ids and prune out remaining VN_TOPs
from dead code. */ from dead code. */
...@@ -5027,8 +5021,6 @@ run_scc_vn (vn_lookup_kind default_vn_walk_kind_) ...@@ -5027,8 +5021,6 @@ run_scc_vn (vn_lookup_kind default_vn_walk_kind_)
} }
} }
} }
return true;
} }
/* Return the maximum value id we have ever seen. */ /* Return the maximum value id we have ever seen. */
......
...@@ -212,7 +212,7 @@ enum vn_lookup_kind { VN_NOWALK, VN_WALK, VN_WALKREWRITE }; ...@@ -212,7 +212,7 @@ enum vn_lookup_kind { VN_NOWALK, VN_WALK, VN_WALKREWRITE };
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);
bool run_scc_vn (vn_lookup_kind); void run_scc_vn (vn_lookup_kind);
void free_scc_vn (void); void free_scc_vn (void);
void scc_vn_restore_ssa_info (void); void scc_vn_restore_ssa_info (void);
tree vn_nary_op_lookup (tree, vn_nary_op_t *); tree vn_nary_op_lookup (tree, vn_nary_op_t *);
......
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