genrecog.c (nodes_identical): Expand commentary.
authorRichard Henderson <rth@redhat.com>
Sat, 13 Jan 2001 19:31:07 +0000 (11:31 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Sat, 13 Jan 2001 19:31:07 +0000 (11:31 -0800)
        * genrecog.c (nodes_identical): Expand commentary.
        (write_switch): Watch out for identical nodes.

From-SVN: r38989

gcc/ChangeLog
gcc/genrecog.c

index 91d328aef1e62d11f6bfa635d33280722203a45f..e5d71d94b56c2485b987c49316cbfcef3ecd038e 100644 (file)
@@ -1,3 +1,8 @@
+2001-01-13  Richard Henderson  <rth@redhat.com>
+
+       * genrecog.c (nodes_identical): Expand commentary.
+       (write_switch): Watch out for identical nodes.
+
 2001-01-13  Neil Booth  <neil@daikokuya.demon.co.uk>
 
         * cppfiles.c (_cpp_fake_include): New function.
index 8146b7141b002585d4cfc4d1b37bc3c9a72c5d3d..80d680a42922738e84bf2fda221a62e1b91b3ee1 100644 (file)
@@ -1297,7 +1297,9 @@ nodes_identical (d1, d2)
     return 0;
 
   /* Check that their subnodes are at the same position, as any one set
-     of sibling decisions must be at the same position.  */
+     of sibling decisions must be at the same position.  Allowing this
+     requires complications to find_afterward and when change_state is
+     invoked.  */
   if (d1->success.first
       && d2->success.first
       && strcmp (d1->success.first->position, d2->success.first->position))
@@ -1743,7 +1745,8 @@ write_switch (start, depth)
   if (!p->next
       || p->tests->next
       || p->next->tests->type != type
-      || p->next->tests->next)
+      || p->next->tests->next
+      || nodes_identical_1 (p->tests, p->next->tests))
     return p;
 
   /* DT_code is special in that we can do interesting things with
@@ -1866,6 +1869,14 @@ write_switch (start, depth)
 
       do
        {
+         /* Merge trees will not unify identical nodes if their
+            sub-nodes are at different levels.  Thus we must check
+            for duplicate cases.  */
+         struct decision *q;
+         for (q = start; q != p; q = q->next)
+           if (nodes_identical_1 (p->tests, q->tests))
+             goto case_done;
+
          if (p != start && p->need_label && needs_label == NULL)
            needs_label = p;
 
@@ -1892,7 +1903,8 @@ write_switch (start, depth)
          p = p->next;
        }
       while (p && p->tests->type == type && !p->tests->next);
-      
+
+    case_done:
       printf ("    default:\n      break;\n    }\n");
 
       return needs_label != NULL ? needs_label : p;