Commit da9a8da8 by Jeff Law Committed by Jeff Law

re PR testsuite/68580 (FAIL: c-c++-common/tsan/pr65400-1.c -O0 execution test)

	PR tree-optimization/68580
	* params.def (FSM_MAXIMUM_PHI_ARGUMENTS): New param.
	* tree-ssa-threadbackward.c
	(fsm_find_control_statement_thread_paths): Do not try to walk
	through large PHI nodes.

From-SVN: r233053
parent 800cb72a
2016-02-01 Jeff Law <law@redhat.com>
PR tree-optimization/68580
* params.def (FSM_MAXIMUM_PHI_ARGUMENTS): New param.
* tree-ssa-threadbackward.c
(fsm_find_control_statement_thread_paths): Do not try to walk
through large PHI nodes.
2016-02-01 Jakub Jelinek <jakub@redhat.com> 2016-02-01 Jakub Jelinek <jakub@redhat.com>
* ifcvt.c (bb_ok_for_noce_convert_multiple_sets): Return false * ifcvt.c (bb_ok_for_noce_convert_multiple_sets): Return false
......
...@@ -1150,6 +1150,11 @@ DEFPARAM (PARAM_FSM_SCALE_PATH_STMTS, ...@@ -1150,6 +1150,11 @@ DEFPARAM (PARAM_FSM_SCALE_PATH_STMTS,
"Scale factor to apply to the number of statements in a threading path when comparing to the number of (scaled) blocks.", "Scale factor to apply to the number of statements in a threading path when comparing to the number of (scaled) blocks.",
2, 1, 10) 2, 1, 10)
DEFPARAM (PARAM_FSM_MAXIMUM_PHI_ARGUMENTS,
"fsm-maximum-phi-arguments",
"Maximum number of arguments a PHI may have before the FSM threader will not try to thread through its block.",
100, 1, 999999)
DEFPARAM (PARAM_FSM_SCALE_PATH_BLOCKS, DEFPARAM (PARAM_FSM_SCALE_PATH_BLOCKS,
"fsm-scale-path-blocks", "fsm-scale-path-blocks",
"Scale factor to apply to the number of blocks in a threading path when comparing to the number of (scaled) statements.", "Scale factor to apply to the number of blocks in a threading path when comparing to the number of (scaled) statements.",
......
...@@ -114,7 +114,9 @@ fsm_find_control_statement_thread_paths (tree name, ...@@ -114,7 +114,9 @@ fsm_find_control_statement_thread_paths (tree name,
eventually one of the phi arguments will be an integer constant. In the eventually one of the phi arguments will be an integer constant. In the
future, this could be extended to also handle simple assignments of future, this could be extended to also handle simple assignments of
arithmetic operations. */ arithmetic operations. */
if (gimple_code (def_stmt) != GIMPLE_PHI) if (gimple_code (def_stmt) != GIMPLE_PHI
|| (gimple_phi_num_args (def_stmt)
>= (unsigned) PARAM_VALUE (PARAM_FSM_MAXIMUM_PHI_ARGUMENTS)))
return; return;
/* Avoid infinite recursion. */ /* Avoid infinite recursion. */
...@@ -200,6 +202,9 @@ fsm_find_control_statement_thread_paths (tree name, ...@@ -200,6 +202,9 @@ fsm_find_control_statement_thread_paths (tree name,
/* Iterate over the arguments of PHI. */ /* Iterate over the arguments of PHI. */
unsigned int i; unsigned int i;
if (gimple_phi_num_args (phi)
< (unsigned) PARAM_VALUE (PARAM_FSM_MAXIMUM_PHI_ARGUMENTS))
{
for (i = 0; i < gimple_phi_num_args (phi); i++) for (i = 0; i < gimple_phi_num_args (phi); i++)
{ {
tree arg = gimple_phi_arg_def (phi, i); tree arg = gimple_phi_arg_def (phi, i);
...@@ -212,7 +217,8 @@ fsm_find_control_statement_thread_paths (tree name, ...@@ -212,7 +217,8 @@ fsm_find_control_statement_thread_paths (tree name,
if (TREE_CODE (arg) == SSA_NAME) if (TREE_CODE (arg) == SSA_NAME)
{ {
vec_safe_push (path, bbi); vec_safe_push (path, bbi);
/* Recursively follow SSA_NAMEs looking for a constant definition. */ /* Recursively follow SSA_NAMEs looking for a constant
definition. */
fsm_find_control_statement_thread_paths (arg, visited_bbs, path, fsm_find_control_statement_thread_paths (arg, visited_bbs, path,
seen_loop_phi); seen_loop_phi);
...@@ -239,8 +245,8 @@ fsm_find_control_statement_thread_paths (tree name, ...@@ -239,8 +245,8 @@ fsm_find_control_statement_thread_paths (tree name,
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "FSM jump-thread path not considered: " fprintf (dump_file, "FSM jump-thread path not considered: "
"the number of previously recorded FSM paths to thread " "the number of previously recorded FSM paths to "
"exceeds PARAM_MAX_FSM_THREAD_PATHS.\n"); "thread exceeds PARAM_MAX_FSM_THREAD_PATHS.\n");
continue; continue;
} }
...@@ -258,9 +264,9 @@ fsm_find_control_statement_thread_paths (tree name, ...@@ -258,9 +264,9 @@ fsm_find_control_statement_thread_paths (tree name,
bool threaded_multiway_branch = false; bool threaded_multiway_branch = false;
/* Count the number of instructions on the path: as these instructions /* Count the number of instructions on the path: as these instructions
will have to be duplicated, we will not record the path if there are will have to be duplicated, we will not record the path if there
too many instructions on the path. Also check that all the blocks in are too many instructions on the path. Also check that all the
the path belong to a single loop. */ blocks in the path belong to a single loop. */
for (j = 0; j < path_length; j++) for (j = 0; j < path_length; j++)
{ {
basic_block bb = (*path)[j]; basic_block bb = (*path)[j];
...@@ -384,13 +390,14 @@ fsm_find_control_statement_thread_paths (tree name, ...@@ -384,13 +390,14 @@ fsm_find_control_statement_thread_paths (tree name,
} }
/* We avoid creating irreducible inner loops unless we thread through /* We avoid creating irreducible inner loops unless we thread through
a multiway branch, in which case we have deemed it worth losing other a multiway branch, in which case we have deemed it worth losing
loop optimizations later. other loop optimizations later.
We also consider it worth creating an irreducible inner loop if We also consider it worth creating an irreducible inner loop if
the number of copied statement is low relative to the length of the number of copied statement is low relative to the length of
the path -- in that case there's little the traditional loop optimizer the path -- in that case there's little the traditional loop
would have done anyway, so an irreducible loop is not so bad. */ optimizer would have done anyway, so an irreducible loop is not
so bad. */
if (!threaded_multiway_branch && creates_irreducible_loop if (!threaded_multiway_branch && creates_irreducible_loop
&& (n_insns * PARAM_VALUE (PARAM_FSM_SCALE_PATH_STMTS) && (n_insns * PARAM_VALUE (PARAM_FSM_SCALE_PATH_STMTS)
> path_length * PARAM_VALUE (PARAM_FSM_SCALE_PATH_BLOCKS))) > path_length * PARAM_VALUE (PARAM_FSM_SCALE_PATH_BLOCKS)))
...@@ -442,6 +449,7 @@ fsm_find_control_statement_thread_paths (tree name, ...@@ -442,6 +449,7 @@ fsm_find_control_statement_thread_paths (tree name,
/* Remove BBI from the path. */ /* Remove BBI from the path. */
path->pop (); path->pop ();
} }
}
/* Remove all the nodes that we added from NEXT_PATH. */ /* Remove all the nodes that we added from NEXT_PATH. */
if (next_path_length) if (next_path_length)
......
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