public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/37285]  New: [4.4 Regression] ICE while building binutils on ppc
@ 2008-08-30  1:30 pinskia at gcc dot gnu dot org
  2008-08-30  1:30 ` [Bug middle-end/37285] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-30  1:30 UTC (permalink / raw)
  To: gcc-bugs

Hi, it looks like some of the VRP enhancements for switch statements is causing
an ICE on some code in binutils.
Testcase:
_bfd_xcoff_canonicalize_dynamic_reloc (unsigned long long l_symndx)
{
  if (l_symndx < 3)
    {
      switch (l_symndx)
      {
        case 0:
        case 1:
         break;
        case 2:
         _bfd_abort ("HI");
    }
  }
}
--- CUT ---
With VRP turned on we get:
  switch (l_symndx) <case 0 ... 1: <L4>, case 2: <L3>>

But without it turned on we get:
  switch (l_symndx) <default: <L4>, case 2: <L3>>

Most likely caused by the patch to fix PR 14495.


-- 
           Summary: [4.4 Regression] ICE while building binutils on ppc
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
GCC target triplet: powerpc-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37285


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
  2008-08-30  1:30 [Bug middle-end/37285] New: [4.4 Regression] ICE while building binutils on ppc pinskia at gcc dot gnu dot org
@ 2008-08-30  1:30 ` pinskia at gcc dot gnu dot org
  2008-08-30 14:12 ` rguenth at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-30  1:30 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |blocker
   Target Milestone|---                         |4.4.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37285


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
  2008-08-30  1:30 [Bug middle-end/37285] New: [4.4 Regression] ICE while building binutils on ppc pinskia at gcc dot gnu dot org
  2008-08-30  1:30 ` [Bug middle-end/37285] " pinskia at gcc dot gnu dot org
@ 2008-08-30 14:12 ` rguenth at gcc dot gnu dot org
  2008-08-30 22:18 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-08-30 14:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-08-30 14:10 -------
What is the ICE?  and with what options?  I get the same IL on i?86 but no
ICE.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37285


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
  2008-08-30  1:30 [Bug middle-end/37285] New: [4.4 Regression] ICE while building binutils on ppc pinskia at gcc dot gnu dot org
  2008-08-30  1:30 ` [Bug middle-end/37285] " pinskia at gcc dot gnu dot org
  2008-08-30 14:12 ` rguenth at gcc dot gnu dot org
@ 2008-08-30 22:18 ` pinskia at gcc dot gnu dot org
  2008-08-30 22:28 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-30 22:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-08-30 22:17 -------
../../src/bfd/xcofflink.c: In function '_bfd_xcoff_canonicalize_dynamic_reloc':
../../src/bfd/xcofflink.c:399: internal compiler error: in purge_dead_edges, at
cfgrtl.c:2327
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


-O1 -ftree-vrp is enough to reproduce the bug which shows the middle-end is not
ready for the IR changes that are done by VRP.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |UNCONFIRMED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37285


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
  2008-08-30  1:30 [Bug middle-end/37285] New: [4.4 Regression] ICE while building binutils on ppc pinskia at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-08-30 22:18 ` pinskia at gcc dot gnu dot org
@ 2008-08-30 22:28 ` pinskia at gcc dot gnu dot org
  2008-08-31 12:00 ` rguenth at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-30 22:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2008-08-30 22:27 -------
One more thing I forgot to mention is that the ICE is during expand time.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37285


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
  2008-08-30  1:30 [Bug middle-end/37285] New: [4.4 Regression] ICE while building binutils on ppc pinskia at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-08-30 22:28 ` pinskia at gcc dot gnu dot org
@ 2008-08-31 12:00 ` rguenth at gcc dot gnu dot org
  2008-09-09 20:32 ` jsm28 at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-08-31 12:00 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
  2008-08-30  1:30 [Bug middle-end/37285] New: [4.4 Regression] ICE while building binutils on ppc pinskia at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-08-31 12:00 ` rguenth at gcc dot gnu dot org
@ 2008-09-09 20:32 ` jsm28 at gcc dot gnu dot org
  2008-10-01 13:22 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-09-09 20:32 UTC (permalink / raw)
  To: gcc-bugs



-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37285


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
  2008-08-30  1:30 [Bug middle-end/37285] New: [4.4 Regression] ICE while building binutils on ppc pinskia at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2008-09-09 20:32 ` jsm28 at gcc dot gnu dot org
@ 2008-10-01 13:22 ` rguenth at gcc dot gnu dot org
  2008-10-01 13:28 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-01 13:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2008-10-01 13:20 -------
Note that after tuples we always have a default label again, just the default
label isn't a default label.  I have a patch to fix that, sort of

Index: tree-vrp.c
===================================================================
*** tree-vrp.c  (revision 140810)
--- tree-vrp.c  (working copy)
*************** execute_vrp (void)
*** 7149,7157 ****
--- 7149,7164 ----
      {
        size_t j;
        size_t n = TREE_VEC_LENGTH (su->vec);
+       tree label;
        gimple_switch_set_num_labels (su->stmt, n);
        for (j = 0; j < n; j++)
        gimple_switch_set_label (su->stmt, j, TREE_VEC_ELT (su->vec, j));
+       /* As we may have replaced the default label with a regular one
+        make sure to make it a real default label again.  This ensures
+        optimal expansion.  */
+       label = gimple_switch_default_label (su->stmt);
+       CASE_LOW (label) = NULL_TREE;
+       CASE_HIGH (label) = NULL_TREE;
      }

    if (VEC_length (edge, to_remove_edges) > 0)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37285


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
  2008-08-30  1:30 [Bug middle-end/37285] New: [4.4 Regression] ICE while building binutils on ppc pinskia at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2008-10-01 13:22 ` rguenth at gcc dot gnu dot org
@ 2008-10-01 13:28 ` rguenth at gcc dot gnu dot org
  2008-10-01 15:11 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-01 13:28 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-08-31 11:59:27         |2008-10-01 13:27:26
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37285


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
  2008-08-30  1:30 [Bug middle-end/37285] New: [4.4 Regression] ICE while building binutils on ppc pinskia at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2008-10-01 13:28 ` rguenth at gcc dot gnu dot org
@ 2008-10-01 15:11 ` rguenth at gcc dot gnu dot org
  2008-10-01 15:12 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-01 15:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2008-10-01 15:09 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37285


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
  2008-08-30  1:30 [Bug middle-end/37285] New: [4.4 Regression] ICE while building binutils on ppc pinskia at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2008-10-01 15:11 ` rguenth at gcc dot gnu dot org
@ 2008-10-01 15:12 ` rguenth at gcc dot gnu dot org
  2008-10-02  9:13 ` jakub at gcc dot gnu dot org
  2008-10-02  9:14 ` jakub at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-01 15:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rguenth at gcc dot gnu dot org  2008-10-01 15:11 -------
Subject: Bug 37285

Author: rguenth
Date: Wed Oct  1 15:09:26 2008
New Revision: 140814

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140814
Log:
2008-10-01  Richard Guenther  <rguenther@suse.de>

        PR middle-end/37285
        * tree-vrp.c (execute_vrp): If we optimized away the default
        case make sure to promote the label that got in place of it
        to a default case label.

        * gcc.c-torture/compile/pr37285.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr37285.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vrp.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37285


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
  2008-08-30  1:30 [Bug middle-end/37285] New: [4.4 Regression] ICE while building binutils on ppc pinskia at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2008-10-01 15:12 ` rguenth at gcc dot gnu dot org
@ 2008-10-02  9:13 ` jakub at gcc dot gnu dot org
  2008-10-02  9:14 ` jakub at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-10-02  9:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jakub at gcc dot gnu dot org  2008-10-02 09:11 -------
*** Bug 37666 has been marked as a duplicate of this bug. ***


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |joel at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37285


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug middle-end/37285] [4.4 Regression] ICE while building binutils on ppc
  2008-08-30  1:30 [Bug middle-end/37285] New: [4.4 Regression] ICE while building binutils on ppc pinskia at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2008-10-02  9:13 ` jakub at gcc dot gnu dot org
@ 2008-10-02  9:14 ` jakub at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-10-02  9:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jakub at gcc dot gnu dot org  2008-10-02 09:12 -------
*** Bug 35874 has been marked as a duplicate of this bug. ***


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mstein dot lists at
                   |                            |googlemail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37285


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-10-02  9:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-30  1:30 [Bug middle-end/37285] New: [4.4 Regression] ICE while building binutils on ppc pinskia at gcc dot gnu dot org
2008-08-30  1:30 ` [Bug middle-end/37285] " pinskia at gcc dot gnu dot org
2008-08-30 14:12 ` rguenth at gcc dot gnu dot org
2008-08-30 22:18 ` pinskia at gcc dot gnu dot org
2008-08-30 22:28 ` pinskia at gcc dot gnu dot org
2008-08-31 12:00 ` rguenth at gcc dot gnu dot org
2008-09-09 20:32 ` jsm28 at gcc dot gnu dot org
2008-10-01 13:22 ` rguenth at gcc dot gnu dot org
2008-10-01 13:28 ` rguenth at gcc dot gnu dot org
2008-10-01 15:11 ` rguenth at gcc dot gnu dot org
2008-10-01 15:12 ` rguenth at gcc dot gnu dot org
2008-10-02  9:13 ` jakub at gcc dot gnu dot org
2008-10-02  9:14 ` jakub at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).