Bug 80707 - [8 Regression] r247844 causes error: extra outgoing edge
Summary: [8 Regression] r247844 causes error: extra outgoing edge
Status: CLOSED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 8.0
: P1 normal
Target Milestone: 8.0
Assignee: Peter Bergner
URL: https://gcc.gnu.org/ml/gcc-patches/20...
Keywords: wrong-code
: 80714 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-05-11 06:02 UTC by Markus Trippelsdorf
Modified: 2017-05-12 17:19 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-05-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2017-05-11 06:02:36 UTC
Since r247844:

trippels@gcc2-power8 ~ % cat tzfmt.ii
struct A {
  int m_fn1(int &) const;
};
int A::m_fn1(int &p1) const {
  int a[6];
  int b = 0;
  for (int i;; i++) {
    if (a[i])
      break;
    b++;
  }
  while (b) {
    int c;
    switch (b) {
    case 1:
      c = 0;
      break;
    case 5:
      c = a[0];
    }
    if (c)
      p1 = 0;
    b--;
  }
}

trippels@gcc2-power8 ~ % g++ -c -O3 tzfmt.ii
tzfmt.ii: In member function ‘int A::m_fn1(int&) const’:
tzfmt.ii:4:5: error: extra outgoing edge 43->33
 int A::m_fn1(int &p1) const {
     ^
tzfmt.ii:4:5: error: extra outgoing edge 44->33
tzfmt.ii:4:5: internal compiler error: verify_flow_info failed
0x105d8db3 verify_flow_info()
        ../../gcc/gcc/cfghooks.c:260
0x10bb613b checking_verify_flow_info
        ../../gcc/gcc/cfghooks.h:198
0x10bb613b cleanup_tree_cfg_noloop
        ../../gcc/gcc/tree-cfgcleanup.c:837
0x10bb613b cleanup_tree_cfg()
        ../../gcc/gcc/tree-cfgcleanup.c:883
0x10a3c147 execute_function_todo
        ../../gcc/gcc/passes.c:1921
0x10a3ced3 do_per_function
        ../../gcc/gcc/passes.c:1652
0x10a3d153 execute_todo
        ../../gcc/gcc/passes.c:2018
Comment 1 Peter Bergner 2017-05-11 12:13:23 UTC
Confirmed.  I'll have a look.
Comment 2 David Binderman 2017-05-11 17:11:06 UTC
Also causes my local gcc bootstrap to fail. 

I think it's the -O3 -march=native causing it.
I'll try a bootstrap with the usual -O2 instead.
Comment 3 Peter Bergner 2017-05-11 22:54:11 UTC
*** Bug 80714 has been marked as a duplicate of this bug. ***
Comment 4 Peter Bergner 2017-05-12 00:09:36 UTC
David and HJ, the following patch fixes the ICE Markus reported, so can you try the following patch to see if it fixes your bootstrap issues?

Index: tree-cfg.c
===================================================================
--- tree-cfg.c	(revision 247845)
+++ tree-cfg.c	(working copy)
@@ -1684,6 +1684,10 @@ group_case_labels_stmt (gswitch *stmt)
 	  || (EDGE_COUNT (base_bb->succs) == 0
 	      && gimple_seq_unreachable_p (bb_seq (base_bb))))
 	{
+	  edge e;
+	  if (base_bb != default_bb
+	      && (e = find_edge (gimple_bb (stmt), base_bb)) != NULL)
+	    remove_edge_and_dominated_blocks (e);
 	  gimple_switch_set_label (stmt, i, NULL_TREE);
 	  i++;
 	  new_size--;
Comment 5 David Binderman 2017-05-12 08:50:18 UTC
Seems to work for me.
Comment 6 H.J. Lu 2017-05-12 16:07:06 UTC
It works.  Thanks.
Comment 7 Peter Bergner 2017-05-12 16:52:04 UTC
Patch submitted.
Comment 8 Peter Bergner 2017-05-12 17:13:38 UTC
Author: bergner
Date: Fri May 12 17:13:07 2017
New Revision: 247984

URL: https://gcc.gnu.org/viewcvs?rev=247984&root=gcc&view=rev
Log:
gcc/
	PR middle-end/80707
	* tree-cfg.c: Remove cfg edges of unreachable case statements.

gcc/testsuite/
	PR middle-end/80707
	* g++.dg/pr80707.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/pr80707.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-cfg.c
Comment 9 Peter Bergner 2017-05-12 17:16:27 UTC
Fixed.
Comment 10 Peter Bergner 2017-05-12 17:19:45 UTC
Closing as fixed.