From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9509 invoked by alias); 31 Aug 2008 12:00:50 -0000 Received: (qmail 8677 invoked by uid 48); 31 Aug 2008 11:59:27 -0000 Date: Sun, 31 Aug 2008 12:00:00 -0000 Message-ID: <20080831115927.8676.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rguenth at gcc dot gnu dot org" 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 X-SW-Source: 2008-08/txt/msg02497.txt.bz2 ------- Comment #4 from rguenth at gcc dot gnu dot org 2008-08-31 11:59 ------- The code in purge_dead_edges looks broken. /* If we don't see a jump insn, we don't know exactly why the block would have been broken at this point. Look for a simple, non-fallthru edge, as these are only created by conditional branches. If we find such an edge we know that there used to be a jump here and can then safely remove all non-fallthru edges. */ but for switches we never have an edge with fallthru set (at least not on the tree level, even before VRP runs). And the splitting code now splits ;; basic block 3, loop depth 0, count 0 ;; prev block 12, next block 4 ;; pred: 12 [100.0%] (fallthru) ;; succ: 5 [61.0%] 4 [39.0%] (note 17 51 18 3 [bb 3] NOTE_INSN_BASIC_BLOCK) (insn 18 17 19 3 t.i:5 (set (reg:DI 3 3) (reg/v:DI 120 [ l_symndx ])) -1 (nil)) (insn 19 18 20 3 t.i:5 (set (reg:DI 5 5) (const_int 1 [0x1])) -1 (nil)) (call_insn/u 20 19 21 3 t.i:5 (parallel [ (set (reg:SI 3 3) (call (mem:SI (symbol_ref:SI ("__ucmpdi2") [flags 0x41]) [0 S4 A8]) (const_int 0 [0x0]))) (use (const_int 16 [0x10])) (clobber (reg:SI 65 lr)) ]) -1 (expr_list:REG_EH_REGION (const_int 0 [0x0]) (nil)) (expr_list:REG_DEP_TRUE (use (reg:DI 5 5)) (expr_list:REG_DEP_TRUE (use (reg:DI 3 3)) (nil)))) (insn 21 20 22 3 t.i:5 (set (reg:CCUNS 125) (compare:CCUNS (reg:SI 3 3) (const_int 1 [0x1]))) -1 (nil)) (jump_insn 22 21 23 3 t.i:5 (set (pc) (if_then_else (leu (reg:CCUNS 125) (const_int 0 [0x0])) (label_ref 36) (pc))) -1 (nil)) (insn 23 22 24 3 t.i:5 (set (reg:CC 126) (compare:CC (subreg:SI (reg/v:DI 120 [ l_symndx ]) 0) (const_int 0 [0x0]))) -1 (nil)) (jump_insn 24 23 25 3 t.i:5 (set (pc) (if_then_else (ne (reg:CC 126) (const_int 0 [0x0])) (label_ref 29) (pc))) -1 (nil)) (insn 25 24 26 3 t.i:5 (set (reg:CC 127) (compare:CC (subreg:SI (reg/v:DI 120 [ l_symndx ]) 4) (const_int 2 [0x2]))) -1 (nil)) (jump_insn 26 25 27 3 t.i:5 (set (pc) (if_then_else (ne (reg:CC 127) (const_int 0 [0x0])) (label_ref 29) (pc))) -1 (nil)) (jump_insn 27 26 28 3 t.i:5 (set (pc) (label_ref 30)) -1 (nil)) (barrier 28 27 29) (code_label 29 28 30 3 5 "" [2 uses]) at the jump target (code_label 29 28 30 3 5 "" [2 uses]) so we enter purge_dead_edges with ;; basic block 16, loop depth 0, count 0 ;; prev block 15, next block 4 ;; pred: ;; succ: 5 [61.0%] 4 [39.0%] (code_label 29 28 55 16 5 "" [2 uses]) (note 55 29 30 16 [bb 16] NOTE_INSN_BASIC_BLOCK) so in the end it looks like we can remove the assert which leaves us with (IMHO, my ppc fu is not too great) correct assembly generated. Proposed patch: Index: gcc/cfgrtl.c =================================================================== --- gcc/cfgrtl.c (revision 139823) +++ gcc/cfgrtl.c (working copy) @@ -2324,10 +2324,11 @@ purge_dead_edges (basic_block bb) ei_next (&ei); } - gcc_assert (single_succ_p (bb)); - - single_succ_edge (bb)->probability = REG_BR_PROB_BASE; - single_succ_edge (bb)->count = bb->count; + if (single_succ_p (bb)) + { + single_succ_edge (bb)->probability = REG_BR_PROB_BASE; + single_succ_edge (bb)->count = bb->count; + } if (dump_file) fprintf (dump_file, "Purged non-fallthru edges from bb %i\n", But this also shows a missed optimization as we now no longer merge the case 0 ...1 range with the default case. Before VRP we have switch (l_symndx_1(D)) , case 0 ... 1: , case 2: > so we could easily detect this. Can you verify the generated assembly is correct with the proposed patch? Thanks. -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2008-08-31 11:59:27 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37285