From: Peter Bergner Date: Thu, 27 Jul 2017 14:05:14 +0000 (-0500) Subject: re PR middle-end/81564 (ICE in group_case_labels_stmt()) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=27c8b49bfc23b658bc8ea90e653f76e26e856c43;p=gcc.git re PR middle-end/81564 (ICE in group_case_labels_stmt()) gcc/ PR middle-end/81564 * tree-cfg.c (group_case_labels_stmt): Handle already deleted blocks. gcc/testsuite/ PR middle-end/81564 * gcc.dg/pr81564.c: New test. From-SVN: r250628 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 77a77ebca7f..05107fd93fc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-07-27 Peter Bergner + + PR middle-end/81564 + * tree-cfg.c (group_case_labels_stmt): Handle already deleted blocks. + 2017-07-27 Richard Biener PR tree-optimization/81573 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fe0b88c84fe..a57caaa65cb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-07-27 Peter Bergner + + PR middle-end/81564 + * gcc.dg/pr81564.c: New test. + 2017-07-27 Richard Biener PR tree-optimization/81573 diff --git a/gcc/testsuite/gcc.dg/pr81564.c b/gcc/testsuite/gcc.dg/pr81564.c new file mode 100644 index 00000000000..13519991f17 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr81564.c @@ -0,0 +1,21 @@ +/* PR middle-end/81564 ICE in group_case_labels_stmt(). */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct a { + int b; + int c; +}; + +void +foo (void) +{ + struct a *e; + switch (e->c) + { + case 7: + case 3: + if (__builtin_expect(!0, 0)) + __builtin_unreachable(); + } +} diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 83e4ee60e9f..f664ffe119a 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -1701,8 +1701,9 @@ group_case_labels_stmt (gswitch *stmt) gcc_assert (base_case); base_bb = label_to_block (CASE_LABEL (base_case)); - /* Discard cases that have the same destination as the default case. */ - if (base_bb == default_bb) + /* Discard cases that have the same destination as the default case or + whose destiniation blocks have already been removed as unreachable. */ + if (base_bb == NULL || base_bb == default_bb) { i++; continue;