OSDN Git Service

2004-10-01 Andrew Pinski <pinskia@physics.uc.edu>
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Oct 2004 15:22:26 +0000 (15:22 +0000)
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Oct 2004 15:22:26 +0000 (15:22 +0000)
        PR tree-opt/17343
        * gcc.dg/tree-ssa/pr17343.c: New test.

2004-10-01  Andrew Pinski  <pinskia@physics.uc.edu>

        PR tree-opt/17343
        * tree-cfg.c (group_case_labels): Get the label and not
        the case expr for the default case.
        When the label we looking at is the default, decrement the
        new_size.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88397 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr17343.c [new file with mode: 0644]
gcc/tree-cfg.c

index 80912c3..f32a14b 100644 (file)
@@ -1,3 +1,11 @@
+2004-10-01  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR tree-opt/17343
+       * tree-cfg.c (group_case_labels): Get the label and not
+       the case expr for the default case.
+       When the label we looking at is the default, decrement the
+       new_size.
+
 2004-10-01  Jan Hubicka  <jh@suse.cz>
 
        * c-decl.c (c_expand_body): Update call tree_rest_of_compilation.
index 6b3b270..cf4646c 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-01  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR tree-opt/17343
+       * gcc.dg/tree-ssa/pr17343.c: New test.
+
 2004-10-01  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.dg/tree-ssa/stdarg-1.c: Removed.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr17343.c b/gcc/testsuite/gcc.dg/tree-ssa/pr17343.c
new file mode 100644 (file)
index 0000000..b415d66
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
+void foo0(void);
+void foo1(void);
+void foo2(void);
+void foo3(void);
+
+void
+foo (int a)
+{
+  switch (a)
+    {
+    case 10:
+    case 11:
+    case 12:
+    case 13:
+      goto ddd;
+    case 14:
+      foo1();
+      break;
+    case 15:
+      foo2();
+      break;
+    case 16:
+      foo3();
+      break;
+    default:
+    ddd:
+      foo0();
+      break;
+    }
+}
+/* There should be precisely two references to ddd.  One in the switch
+   and one for the label, we used not to combine the case 10-13 into
+   the default case.  */
+/* { dg-final { scan-tree-dump-times "ddd" 1 "optimized"} } */
index 72f7378..e047943 100644 (file)
@@ -941,7 +941,12 @@ group_case_labels (void)
          tree labels = SWITCH_LABELS (stmt);
          int old_size = TREE_VEC_LENGTH (labels);
          int i, j, new_size = old_size;
-         tree default_label = TREE_VEC_ELT (labels, old_size - 1);
+         tree default_case = TREE_VEC_ELT (labels, old_size - 1);
+         tree default_label;
+
+         /* The default lable is always the last case in a switch
+            statement after gimplification.  */
+         default_label = CASE_LABEL (default_case);
 
          /* Look for possible opportunities to merge cases.
             Ignore the last element of the label vector because it
@@ -961,6 +966,7 @@ group_case_labels (void)
                {
                  TREE_VEC_ELT (labels, i) = NULL_TREE;
                  i++;
+                 new_size--;
                  continue;
                }