Make expansion of balanced binary trees of switches on tree level.

2017-08-29  Martin Liska  <mliska@suse.cz>

	* passes.def: Include pass_lower_switch.
	* stmt.c (dump_case_nodes): Remove and move to
	tree-switch-conversion.
	(case_values_threshold): Likewise.
	(expand_switch_as_decision_tree_p): Likewise.
	(emit_case_decision_tree): Likewise.
	(expand_case): Likewise.
	(balance_case_nodes): Likewise.
	(node_has_low_bound): Likewise.
	(node_has_high_bound): Likewise.
	(node_is_bounded): Likewise.
	(emit_case_nodes): Likewise.
	(struct simple_case_node): New struct.
	(add_case_node): Remove.
	(emit_case_dispatch_table): Use vector instead of case_list.
	(reset_out_edges_aux): Remove.
	(compute_cases_per_edge): Likewise.
	(expand_case): Build list of simple_case_node.
	(expand_sjlj_dispatch_table): Use it.
	* tree-switch-conversion.c (struct case_node): Moved from
	stmt.c and adjusted.
	(emit_case_nodes): Likewise.
	(node_has_low_bound): Likewise.
	(node_has_high_bound): Likewise.
	(node_is_bounded): Likewise.
	(case_values_threshold): Likewise.
	(reset_out_edges_aux): Likewise.
	(compute_cases_per_edge): Likewise.
	(add_case_node): Likewise.
	(dump_case_nodes): Likewise.
	(balance_case_nodes): Likewise.
	(expand_switch_as_decision_tree_p): Likewise.
	(emit_jump): Likewise.
	(emit_case_decision_tree): Likewise.
	(try_switch_expansion): Likewise.
	(do_jump_if_equal): Likewise.
	(emit_cmp_and_jump_insns): Likewise.
	(fix_phi_operands_for_edge): New function.
	(record_phi_operand_mapping): Likewise.
	(class pass_lower_switch): New pass.
	(pass_lower_switch::execute): New function.
	(make_pass_lower_switch): Likewise.
	(conditional_probability):
	* timevar.def: Add TV_TREE_SWITCH_LOWERING.
	* tree-pass.h: Add make_pass_lower_switch.
2017-08-29  Martin Liska  <mliska@suse.cz>

	* gcc.dg/tree-prof/update-loopch.c: Scan patterns in
	switchlower.
	* gcc.dg/tree-ssa/vrp104.c: Likewise.

From-SVN: r251412
This commit is contained in:
Martin Liska 2017-08-29 16:12:44 +02:00 committed by Martin Liska
parent 10bcba61fc
commit 9dc3d6a961
9 changed files with 1270 additions and 997 deletions

View File

@ -1,3 +1,51 @@
2017-08-29 Martin Liska <mliska@suse.cz>
* passes.def: Include pass_lower_switch.
* stmt.c (dump_case_nodes): Remove and move to
tree-switch-conversion.
(case_values_threshold): Likewise.
(expand_switch_as_decision_tree_p): Likewise.
(emit_case_decision_tree): Likewise.
(expand_case): Likewise.
(balance_case_nodes): Likewise.
(node_has_low_bound): Likewise.
(node_has_high_bound): Likewise.
(node_is_bounded): Likewise.
(emit_case_nodes): Likewise.
(struct simple_case_node): New struct.
(add_case_node): Remove.
(emit_case_dispatch_table): Use vector instead of case_list.
(reset_out_edges_aux): Remove.
(compute_cases_per_edge): Likewise.
(expand_case): Build list of simple_case_node.
(expand_sjlj_dispatch_table): Use it.
* tree-switch-conversion.c (struct case_node): Moved from
stmt.c and adjusted.
(emit_case_nodes): Likewise.
(node_has_low_bound): Likewise.
(node_has_high_bound): Likewise.
(node_is_bounded): Likewise.
(case_values_threshold): Likewise.
(reset_out_edges_aux): Likewise.
(compute_cases_per_edge): Likewise.
(add_case_node): Likewise.
(dump_case_nodes): Likewise.
(balance_case_nodes): Likewise.
(expand_switch_as_decision_tree_p): Likewise.
(emit_jump): Likewise.
(emit_case_decision_tree): Likewise.
(try_switch_expansion): Likewise.
(do_jump_if_equal): Likewise.
(emit_cmp_and_jump_insns): Likewise.
(fix_phi_operands_for_edge): New function.
(record_phi_operand_mapping): Likewise.
(class pass_lower_switch): New pass.
(pass_lower_switch::execute): New function.
(make_pass_lower_switch): Likewise.
(conditional_probability):
* timevar.def: Add TV_TREE_SWITCH_LOWERING.
* tree-pass.h: Add make_pass_lower_switch.
2017-08-29 Jozef Lawrynowicz <jozef.l@somniumtech.com>
PR target/80993

View File

@ -394,6 +394,7 @@ along with GCC; see the file COPYING3. If not see
NEXT_PASS (pass_lower_vaarg);
NEXT_PASS (pass_lower_vector);
NEXT_PASS (pass_lower_complex_O0);
NEXT_PASS (pass_lower_switch);
NEXT_PASS (pass_sancov_O0);
NEXT_PASS (pass_asan_O0);
NEXT_PASS (pass_tsan_O0);

1020
gcc/stmt.c

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,9 @@
2017-08-29 Martin Liska <mliska@suse.cz>
* gcc.dg/tree-prof/update-loopch.c: Scan patterns in
switchlower.
* gcc.dg/tree-ssa/vrp104.c: Likewise.
2017-08-29 Richard Biener <rguenther@suse.de>
Dominik Infuehr <dominik.infuehr@theobroma-systems.com>

View File

@ -1,4 +1,4 @@
/* { dg-options "-O2 -fdump-ipa-profile-blocks-details -fdump-tree-optimized-blocks-details" } */
/* { dg-options "-O2 -fdump-ipa-profile-blocks-details -fdump-tree-switchlower-blocks-details" } */
int max = 33333;
int a[8];
int
@ -16,7 +16,7 @@ main ()
edge. */
/* autofdo cannot do that precise counts */
/* { dg-final-use-not-autofdo { scan-ipa-dump "loop depth 1, count 33334" "profile"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump "loop depth 1, count 33333" "optimized"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump-not "loop depth 1, count 33332" "optimized"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump "Removing basic block" "optimized"} } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump "loop depth 1, count 33333" "switchlower"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump-not "loop depth 1, count 33332" "switchlower"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump "Removing basic block" "switchlower"} } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "switchlower"} } */

View File

@ -1,6 +1,6 @@
/* PR tree-optimization/18046 */
/* { dg-options "-O2 -fdump-tree-optimized" } */
/* { dg-final { scan-tree-dump-times "switch" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-times "switch" 1 "switchlower" } } */
void foo (void);
void bar (void);

View File

@ -208,6 +208,7 @@ DEFTIMEVAR (TV_TREE_COPY_RENAME , "tree rename SSA copies")
DEFTIMEVAR (TV_TREE_SSA_VERIFY , "tree SSA verifier")
DEFTIMEVAR (TV_TREE_STMT_VERIFY , "tree STMT verifier")
DEFTIMEVAR (TV_TREE_SWITCH_CONVERSION, "tree switch conversion")
DEFTIMEVAR (TV_TREE_SWITCH_LOWERING, "tree switch lowering")
DEFTIMEVAR (TV_TRANS_MEM , "transactional memory")
DEFTIMEVAR (TV_TREE_STRLEN , "tree strlen optimization")
DEFTIMEVAR (TV_CGRAPH_VERIFY , "callgraph verifier")

View File

@ -409,6 +409,7 @@ extern gimple_opt_pass *make_pass_profile (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_strip_predict_hints (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_lower_complex_O0 (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_lower_complex (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_lower_switch (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_lower_vector (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_lower_vector_ssa (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_lower_omp (gcc::context *ctxt);

File diff suppressed because it is too large Load Diff