From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29440 invoked by alias); 14 Mar 2014 09:18:44 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 29383 invoked by uid 48); 14 Mar 2014 09:18:39 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/60518] [4.9 Regression] ICE: in verify_loop_structure, at cfgloop.c:1647 Date: Fri, 14 Mar 2014 09:18:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-03/txt/msg01139.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60518 --- Comment #3 from Richard Biener --- Ok, so it's branch_prob()s call of split_block that splits the common latch of loops 1 and 2 : (header loop 1) : (header loop 2, latch loop 2 and 1) _2 = fn1 (); if (_2 != 0) goto ; else goto ; the cfghook adjusts the latch of loop 2 properly (bb4s loop father is 2) but fails to notice that bb4 is also the latch of loop 1 ... so this CFG hook loop handling only handles this correctly if we have simple latches (because there the latch always belongs to its loop). Fix: Index: gcc/cfghooks.c =================================================================== --- gcc/cfghooks.c (revision 208536) +++ gcc/cfghooks.c (working copy) @@ -510,9 +510,13 @@ split_block (basic_block bb, void *i) if (current_loops != NULL) { + edge_iterator ei; + edge e; add_bb_to_loop (new_bb, bb->loop_father); - if (bb->loop_father->latch == bb) - bb->loop_father->latch = new_bb; + /* Identify all loops bb may have been the latch of and adjust them. */ + FOR_EACH_EDGE (e, ei, new_bb->succs) + if (e->dest->loop_father->latch == bb) + e->dest->loop_father->latch = new_bb; } res = make_single_succ_edge (bb, new_bb, EDGE_FALLTHRU);