http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59992

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Untested hack to generate somewhat smaller recog_* functions by dynamically
lowering the threshold if we'd see too big functions.  With this patch we get
149 recog_* functions instead of 122, and largest number of lines in one
function decreases from more than 20000 to about 9000.

--- genrecog.c.jj    2014-01-03 11:40:29.000000000 +0100
+++ genrecog.c    2014-02-10 12:21:32.547199720 +0100
@@ -1504,15 +1504,26 @@ simplify_tests (struct decision_head *he
    that is generated.  */

 static int
-break_out_subroutines (struct decision_head *head, int initial)
+break_out_subroutines (struct decision_head *head, int initial, int threshold)
 {
-  int size = 0;
+  int size = 0, t;
   struct decision *sub;

-  for (sub = head->first; sub; sub = sub->next)
-    size += 1 + break_out_subroutines (&sub->success, 0);
+  if (head->first && head->first->subroutine_number)
+    return 1;
+
+  for (t = SUBROUTINE_THRESHOLD;
+       t > SUBROUTINE_THRESHOLD / 2;
+       t -= SUBROUTINE_THRESHOLD / 10)
+    {
+      size = 0;
+      for (sub = head->first; sub; sub = sub->next)
+    size += 1 + break_out_subroutines (&sub->success, 0, t);
+      if (size < SUBROUTINE_THRESHOLD * 5)
+    break;
+    }

-  if (size > SUBROUTINE_THRESHOLD && ! initial)
+  if (size > threshold && ! initial)
     {
       head->first->subroutine_number = ++next_subroutine_number;
       size = 1;
@@ -2486,7 +2497,7 @@ process_tree (struct decision_head *head
       factor_tests (head);

       next_subroutine_number = 0;
-      break_out_subroutines (head, 1);
+      break_out_subroutines (head, 1, SUBROUTINE_THRESHOLD);
       find_afterward (head, NULL);

       /* We run this after find_afterward, because find_afterward needs

Reply via email to