Commit 1acbaa75 by Martin Liska Committed by Martin Liska

Fix thinko in early bail out in tree-switch-conversion.

2019-09-02  Martin Liska  <mliska@suse.cz>

	* tree-switch-conversion.c (jump_table_cluster::find_jump_tables):
	Bail out when we'll end up with the same number of clusters as
	at the beginning.
	(bit_test_cluster::find_bit_tests): Likewise for bit tests.
	(jump_table_cluster::can_be_handled): Remove the guard
	as it's already handled in ::is_enabled.  Allocate output
	after early bail out.

From-SVN: r275293
parent ae0d3f6a
2019-09-02 Martin Liska <mliska@suse.cz> 2019-09-02 Martin Liska <mliska@suse.cz>
* tree-switch-conversion.c (jump_table_cluster::find_jump_tables):
Bail out when we'll end up with the same number of clusters as
at the beginning.
(bit_test_cluster::find_bit_tests): Likewise for bit tests.
(jump_table_cluster::can_be_handled): Remove the guard
as it's already handled in ::is_enabled. Allocate output
after early bail out.
2019-09-02 Martin Liska <mliska@suse.cz>
PR gcov-profile/91601 PR gcov-profile/91601
* gcov.c (path_contains_zero_cycle_arc): Rename to ... * gcov.c (path_contains_zero_cycle_arc): Rename to ...
(path_contains_zero_or_negative_cycle_arc): ... this and handle (path_contains_zero_or_negative_cycle_arc): ... this and handle
......
...@@ -1214,14 +1214,14 @@ jump_table_cluster::find_jump_tables (vec<cluster *> &clusters) ...@@ -1214,14 +1214,14 @@ jump_table_cluster::find_jump_tables (vec<cluster *> &clusters)
} }
/* No result. */ /* No result. */
if (min[l].m_count == INT_MAX) if (min[l].m_count == l)
return clusters.copy (); return clusters.copy ();
vec<cluster *> output; vec<cluster *> output;
output.create (4); output.create (4);
/* Find and build the clusters. */ /* Find and build the clusters. */
for (int end = l;;) for (unsigned int end = l;;)
{ {
int start = min[end].m_start; int start = min[end].m_start;
...@@ -1258,11 +1258,9 @@ jump_table_cluster::can_be_handled (const vec<cluster *> &clusters, ...@@ -1258,11 +1258,9 @@ jump_table_cluster::can_be_handled (const vec<cluster *> &clusters,
make a sequence of conditional branches instead of a dispatch. make a sequence of conditional branches instead of a dispatch.
The definition of "much bigger" depends on whether we are The definition of "much bigger" depends on whether we are
optimizing for size or for speed. */ optimizing for size or for speed.
if (!flag_jump_tables)
return false;
/* For algorithm correctness, jump table for a single case must return For algorithm correctness, jump table for a single case must return
true. We bail out in is_beneficial if it's called just for true. We bail out in is_beneficial if it's called just for
a single case. */ a single case. */
if (start == end) if (start == end)
...@@ -1312,9 +1310,6 @@ jump_table_cluster::is_beneficial (const vec<cluster *> &, ...@@ -1312,9 +1310,6 @@ jump_table_cluster::is_beneficial (const vec<cluster *> &,
vec<cluster *> vec<cluster *>
bit_test_cluster::find_bit_tests (vec<cluster *> &clusters) bit_test_cluster::find_bit_tests (vec<cluster *> &clusters)
{ {
vec<cluster *> output;
output.create (4);
unsigned l = clusters.length (); unsigned l = clusters.length ();
auto_vec<min_cluster_item> min; auto_vec<min_cluster_item> min;
min.reserve (l + 1); min.reserve (l + 1);
...@@ -1337,9 +1332,12 @@ bit_test_cluster::find_bit_tests (vec<cluster *> &clusters) ...@@ -1337,9 +1332,12 @@ bit_test_cluster::find_bit_tests (vec<cluster *> &clusters)
} }
/* No result. */ /* No result. */
if (min[l].m_count == INT_MAX) if (min[l].m_count == l)
return clusters.copy (); return clusters.copy ();
vec<cluster *> output;
output.create (4);
/* Find and build the clusters. */ /* Find and build the clusters. */
for (unsigned end = l;;) for (unsigned end = l;;)
{ {
......
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