re PR tree-optimization/17343 (a dispatch table can be shortened for certain switch statements)

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

        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.

From-SVN: r88397
This commit is contained in:
Andrew Pinski 2004-10-01 15:22:26 +00:00 committed by Andrew Pinski
parent 0f0377f6dd
commit 29c4d22b06
4 changed files with 56 additions and 1 deletions

View 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.

View 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.

View File

@ -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"} } */

View 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;
}