On May 23, 2017 7:46:59 PM GMT+02:00, Peter Bergner
wrote:
>The fix for PR80775 included a thinko bug that caused us to skip some
>case label statements. This leads to problems for test cases where we
>have multiple case labels that point to the same unreachable block, but
>are not mergeable since they don't have consecutive case values.
>This leads to a problem, because we remove the unreachable block when
>handling this first case label, but then we have a dangling reference
>to that block with the skipped case label. The fix is to remove the
>unwanted increment, so that we handle the next case label and end up
>removing it too.
>
>This passed bootstrap and regtesting on powerpc64le-linux with no
>regressions. Is this ok for trunk?
OK.
Richard.
>Peter
>
>gcc/
> PR middle-end/80823
> * tree-cfg.c (group_case_labels_stmt): Delete increment of "i";
>
>gcc/testsuite/
> PR middle-end/80823
> * gcc.dg/pr80823.c: New test.
>
>Index: gcc/tree-cfg.c
>===
>--- gcc/tree-cfg.c (revision 248375)
>+++ gcc/tree-cfg.c (working copy)
>@@ -1726,7 +1726,6 @@ group_case_labels_stmt (gswitch *stmt)
> remove_edge_and_dominated_blocks (base_edge);
> gimple_switch_set_label (stmt, base_index, NULL_TREE);
> new_size--;
>-i++;
> }
> }
>
>Index: gcc/testsuite/gcc.dg/pr80823.c
>===
>--- gcc/testsuite/gcc.dg/pr80823.c (nonexistent)
>+++ gcc/testsuite/gcc.dg/pr80823.c (working copy)
>@@ -0,0 +1,23 @@
>+/* PR middle-end/80823 ICE: verify_flow_info failed */
>+/* { dg-do compile } */
>+/* { dg-options "-O3" } */
>+
>+int a, c;
>+int b[1];
>+static inline int
>+fn1() {
>+ switch (a)
>+ case 0:
>+ case 2:
>+return 1;
>+ return 0;
>+}
>+void fn2() {
>+ int i;
>+ for (;; ++i) {
>+c = b[i];
>+int d = !fn1();
>+if (d)
>+ __asm__("");
>+ }
>+}