Created attachment 36873 [details] C source code $ ../results/bin/gcc -O2 -c -w bug252.c qwe_0.c: In function ‘func_6’: qwe_0.c:195:10: error: loop with header 6 not in loop tree qwe_0.c:195:10: internal compiler error: in verify_loop_structure, at cfgloop.c:1639 0x7395d4 verify_loop_structure() ../../src/trunk/gcc/cfgloop.c:1639 0x9ec0a4 checking_verify_loop_structure ../../src/trunk/gcc/cfgloop.h:324 0x9ec0a4 loop_optimizer_init(unsigned int) ../../src/trunk/gcc/loop-init.c:106 0xd86fc4 init_reassoc ../../src/trunk/gcc/tree-ssa-reassoc.c:5049 Compiler is gcc trunk, dated 20151129.
Confirmed.
Started with r228739.
extern void fn2(int); int a, b, c; void fn1() { int d; for (; b; b++) { a = 7; for (; a;) { jump: fn2(d ?: c); d = 0; } d = c; if (c) goto jump; } goto jump; }
r228739 may have been the trigger, but I think it's uncovering a latent bug in DOM. At first glance it looks like DOM is removing an edge when it simplifies a conditional. That in turn seems to expose two subloops that were previously ignored because they were irreducible -- with the edge removed, those two subloops become reducible. Once the loops are reducible, the loop optimizer wants them to have proper loop structures. They don't and verify_loop_structure aborts. Richi had the suggestion that we should defer those particular CFG manipulations in DOM, which has been on my TODO list. That fixes this problem (the CFG cleanup code will set LOOPS_NEED_FIXUP, which DOM avoids per Richi's request). I've been wanted to analyze any unexpected side effects of doing that, so, now seems to be the right time.
Author: law Date: Thu Dec 10 16:34:43 2015 New Revision: 231527 URL: https://gcc.gnu.org/viewcvs?rev=231527&root=gcc&view=rev Log: 2015-12-10 Jeff Law <law@redhat.com> PR tree-optimization/68619 * tree-ssa-dom.c (dom_opt_dom_walker::before_dom_children): Propgate return value from optimize_stmt. (dom_opt_dom_walker): Add new argument to dom_walker constructor. (pass_dominator:execute): If a block has an unreachable edge, remove all jump threads through any successor of the affected block. (record_equivalences_from_phis): Ignore alternative if the edge does not have EDGE_EXECUTABLE set. (single_incoming_edge_ignoring_loop_edges): Similarly. (optimize_stmt): If a gimple_code has a compile-time constant condition, return the edge taken for that constant value. Also change the condition to true/false as necessary. * domwalk.h (dom_walker::dom_walker): Add new argument skip_unreachable_blocks. Don't provide empty constructor body. (dom_walker::before_dom_children): Change return type. (dom_walker::bb_reachable): Declare new private method. (dom_walker::propagate_unreachable_to_edges): Likewise. (dom_walker::m_unreachable_dom): Declare new private data member. (dom_walker::m_skip_unreachable_blocks): Likewise. * domwalk.c: Include dumpfile.h. (dom_walker::dom_walker): New constructor. Initialize private data members. If needed, set EDGE_EXECUTABLE for all edges in the CFG, extracted from tree-ssa-sccvn.c. (dom_walker::bb_reachable): New method extracted from tree-ssa-sccvn.c (dom_walker::propagate_unreachable_to_edges): Likewise. (dom_walker::walk): Only call before_dom_children on reachable blocks. If before_dom_children returns an edge, then clear EDGE_EXECUTABLE for all other outgoing edges from the same block. For unreachable blocks, call propagate_unreachable_to_edges. Similarly, only call after_dom_children on reachable blocks. For unreachable blocks, conditionally clear m_unreachable_dom. * tree-ssa-sccvn.c (sccvn_dom_walker::unreachable_dom): Remove private data member. (sccvn_dom_walker::after_dom_children): Use methods from dom_walker class. (run_scc_vn): Likewise. (sccvn_dom_walker::before_dom_children): Likewise. Return the taken outgoing edge if a COND, SWITCH, or GOTO are optimized. * compare-elim.c (find_comparison_dom_walker::before_dom_children): Change return type to an edge. Always return NULL. * fwprop.c (single_def_use_dom_walker::before_dom_children): Likewise. * gimple-ssa-strength-reduction.c (find_candidates_dom_walker::before_dom_children): Likewise. * ipa-prop.c (analysis_dom_walker::before_dom_children): Likewise. (ipcp_modif_dom_walker::before_dom_children): Likewise. * tree-into-ssa.c (rewrite_dom_walker::before_dom_children): Likewise. (rewrite_update_dom_walker::before_dom_children): Likewise. (mark_def_dom_children::before_dom_children): Likewise. * tree-ssa-dse.c (dse_dom_walker::before_dom_children): Likewise. * tree-ssa-loop-im.c (invariantness_dom_walker::before_dom_children): Likewise. (move_computations_dom_walker::before_dom_walker): Likewise. * tree-ssa-phiopt.c (nontrapping_dom_walker::before_dom_children): Likewise. * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Likewise. * tree-ssa-propagate.c (substitute_and_fold_dom_walker::before_dom_children): Likewise. * tree-ssa-strlen.c (strlen_dom_walker::before_dom_children): Likewise. * tree-ssa-uncprop.c (uncprop_dom_walker::before_dom_children): Likewise. PR tree-optimization/68619 * gcc.dg/tree-ssa/pr68619-1.c: New test. * gcc.dg/tree-ssa/pr68619-2.c: New test. * gcc.dg/tree-ssa/pr68619-3.c: New test. * gcc.dg/tree-ssa/pr68619-4.c: New test. * gcc.dg/tree-ssa/pr68619-5.c: New test. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/pr68619-1.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr68619-2.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr68619-3.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr68619-4.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr68619-5.c Modified: trunk/gcc/ChangeLog trunk/gcc/compare-elim.c trunk/gcc/domwalk.c trunk/gcc/domwalk.h trunk/gcc/fwprop.c trunk/gcc/gimple-ssa-strength-reduction.c trunk/gcc/ipa-prop.c trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-into-ssa.c trunk/gcc/tree-ssa-dom.c trunk/gcc/tree-ssa-dse.c trunk/gcc/tree-ssa-loop-im.c trunk/gcc/tree-ssa-phiopt.c trunk/gcc/tree-ssa-pre.c trunk/gcc/tree-ssa-propagate.c trunk/gcc/tree-ssa-sccvn.c trunk/gcc/tree-ssa-strlen.c trunk/gcc/tree-ssa-uncprop.c
Fixed on trunk.
Author: uros Date: Thu Dec 10 17:14:07 2015 New Revision: 231532 URL: https://gcc.gnu.org/viewcvs?rev=231532&root=gcc&view=rev Log: PR tree-optimization/68619 * graphite-scop-detection.c (gather_bbs::before_dom_children): Change return type to an edge. Always return NULL. Modified: trunk/gcc/ChangeLog trunk/gcc/graphite-scop-detection.c
(In reply to Jeffrey A. Law from comment #6) > Fixed on trunk. The new test case pr68619-4.c is failing for arm-none-eabi because it triggers the error ---- pr68619-4.c:42:17: error: width of 'code' exceeds its type enum rtx_code code:16; ---- For arm-none-eabi, the rtx_code enum is being represented in 8-bits. so 'enum rtx_code code:8;' compiles without the error. Matthew