public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR middle-end/80823, ICE: verify_flow_info failed
@ 2017-05-23 17:53 Peter Bergner
  2017-05-24  7:18 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Bergner @ 2017-05-23 17:53 UTC (permalink / raw)
  To: GCC Patches; +Cc: Richard Biener, Markus Trippelsdorf, Bill Schmidt

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?

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__("");
+  }
+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix PR middle-end/80823, ICE: verify_flow_info failed
  2017-05-23 17:53 [PATCH] Fix PR middle-end/80823, ICE: verify_flow_info failed Peter Bergner
@ 2017-05-24  7:18 ` Richard Biener
  2017-05-24 13:09   ` Peter Bergner
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2017-05-24  7:18 UTC (permalink / raw)
  To: Peter Bergner, GCC Patches; +Cc: Markus Trippelsdorf, Bill Schmidt

On May 23, 2017 7:46:59 PM GMT+02:00, Peter Bergner <bergner@vnet.ibm.com> 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__("");
>+  }
>+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix PR middle-end/80823, ICE: verify_flow_info failed
  2017-05-24  7:18 ` Richard Biener
@ 2017-05-24 13:09   ` Peter Bergner
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Bergner @ 2017-05-24 13:09 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches, Markus Trippelsdorf, Bill Schmidt

On 5/24/17 2:15 AM, Richard Biener wrote:
> On May 23, 2017 7:46:59 PM GMT+02:00, Peter Bergner <bergner@vnet.ibm.com> wrote:
>> 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.
> 
> OK.
> 

Thanks, committed as revision 248408.

Peter

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-24 12:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23 17:53 [PATCH] Fix PR middle-end/80823, ICE: verify_flow_info failed Peter Bergner
2017-05-24  7:18 ` Richard Biener
2017-05-24 13:09   ` Peter Bergner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).