aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-switch-conversion.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-switch-conversion.c')
-rw-r--r--gcc/tree-switch-conversion.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 186411f..e6a2c7a 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -1183,6 +1183,7 @@ jump_table_cluster::find_jump_tables (vec<cluster *> &clusters)
min.quick_push (min_cluster_item (0, 0, 0));
+ HOST_WIDE_INT attempts = 0;
for (unsigned i = 1; i <= l; i++)
{
/* Set minimal # of clusters with i-th item to infinite. */
@@ -1194,6 +1195,14 @@ jump_table_cluster::find_jump_tables (vec<cluster *> &clusters)
if (i - j < case_values_threshold ())
s += i - j;
+ if (attempts++ == param_max_switch_clustering_attempts)
+ {
+ if (dump_file)
+ fprintf (dump_file, ";; Bail out: "
+ "--param=max-switch-clustering-attempts reached\n");
+ return clusters.copy ();
+ }
+
/* Prefer clusters with smaller number of numbers covered. */
if ((min[j].m_count + 1 < min[i].m_count
|| (min[j].m_count + 1 == min[i].m_count
@@ -1308,6 +1317,7 @@ bit_test_cluster::find_bit_tests (vec<cluster *> &clusters)
min.quick_push (min_cluster_item (0, 0, 0));
+ HOST_WIDE_INT attempts = 0;
for (unsigned i = 1; i <= l; i++)
{
/* Set minimal # of clusters with i-th item to infinite. */
@@ -1315,6 +1325,13 @@ bit_test_cluster::find_bit_tests (vec<cluster *> &clusters)
for (unsigned j = 0; j < i; j++)
{
+ if (attempts++ == param_max_switch_clustering_attempts)
+ {
+ if (dump_file)
+ fprintf (dump_file, ";; Bail out: "
+ "--param=max-switch-clustering-attempts reached\n");
+ return clusters.copy ();
+ }
if (min[j].m_count + 1 < min[i].m_count
&& can_be_handled (clusters, j, i - 1))
min[i] = min_cluster_item (min[j].m_count + 1, j, INT_MAX);