This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Aug 2008 11:59:27 -0000
- Subject: [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
- References: <bug-37285-6528@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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)) <default: <L4>, case 0 ... 1: <L4>, case 2: <L3>>
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