public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/42963]  New: [4,5 Regression] Redundant switch labels not cleaned up anymore
@ 2010-02-04 23:22 steven at gcc dot gnu dot org
  2010-02-05 10:15 ` [Bug tree-optimization/42963] [4.5 " rguenth at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2010-02-04 23:22 UTC (permalink / raw)
  To: gcc-bugs

Test case is taken from bug 18046:
-----------------------------------------------------
extern void foo (void);
extern int i;
void
bar (void)
{
  switch (i)
    {
    case 0:
      foo ();
      break;
    case 1:
      break;
    }


  switch (i)
    {
    case 0:
      foo ();
      break;
    case 1:
      break;
    }
}
-----------------------------------------------------


the .012t.cfg dump with trunk (r156492) today looks like this:

bar ()
{
  int i.0;

<bb 2>:
  i.0 = i;
  switch (i.0) <default: <L2>, case 0: <L0>, case 1: <L2>>

<L0>:
  foo ();

<L2>:
  i.0 = i;
  switch (i.0) <default: <L6>, case 0: <L4>, case 1: <L6>>

<L4>:
  foo ();

<L6>:
  return;

}



The dump with "gcc (Debian 4.3.4-5) 4.3.4" looks better:

bar ()
{
  int i.0;

  # BLOCK 2
  # PRED: ENTRY (fallthru)
  i.0 = i;
  switch (i.0)
    {
      case 0: goto <L0>;
      default : goto <L1>;
    }
  # SUCC: 3 4

  # BLOCK 3
  # PRED: 2
<L0>:;
  foo ();
  # SUCC: 4 (fallthru)

  # BLOCK 4
  # PRED: 2 3 (fallthru)
<L1>:;
  i.0 = i;
  switch (i.0)
    {
      case 0: goto <L4>;
      default : goto <L5>;
    }
  # SUCC: 5 6

  # BLOCK 5
  # PRED: 4
<L4>:;
  foo ();
  # SUCC: 6 (fallthru)

  # BLOCK 6
  # PRED: 4 5 (fallthru)
<L5>:;
  return;
  # SUCC: EXIT

}


Note how GCC 4.5 fails to clean up  the "case 1" label.  The label is retained
all the way through the .137t.nrv dump (at -O2) and only disappears in the
.139t.optimized dump.

This confuses things in a couple of places and costs memory for no reason.


-- 
           Summary: [4,5 Regression] Redundant switch labels not cleaned up
                    anymore
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: steven at gcc dot gnu dot org


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


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

* [Bug tree-optimization/42963] [4.5 Regression] Redundant switch labels not cleaned up anymore
  2010-02-04 23:22 [Bug tree-optimization/42963] New: [4,5 Regression] Redundant switch labels not cleaned up anymore steven at gcc dot gnu dot org
@ 2010-02-05 10:15 ` rguenth at gcc dot gnu dot org
  2010-03-19 16:55 ` matz at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-02-05 10:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2010-02-05 10:15 -------
This optimization was triggered by the useless path which simplified some
jumps before CFG building which did the switch label merging.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matz at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
      Known to work|                            |4.4.3
           Priority|P3                          |P2
   Last reconfirmed|0000-00-00 00:00:00         |2010-02-05 10:15:46
               date|                            |
   Target Milestone|---                         |4.5.0


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


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

* [Bug tree-optimization/42963] [4.5 Regression] Redundant switch labels not cleaned up anymore
  2010-02-04 23:22 [Bug tree-optimization/42963] New: [4,5 Regression] Redundant switch labels not cleaned up anymore steven at gcc dot gnu dot org
  2010-02-05 10:15 ` [Bug tree-optimization/42963] [4.5 " rguenth at gcc dot gnu dot org
@ 2010-03-19 16:55 ` matz at gcc dot gnu dot org
  2010-04-01 13:51 ` steven at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: matz at gcc dot gnu dot org @ 2010-03-19 16:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from matz at gcc dot gnu dot org  2010-03-19 16:55 -------
Actually I have a patch for this, need to polish it somewhat.


-- 

matz at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |matz at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2010-02-05 10:15:46         |2010-03-19 16:55:07
               date|                            |


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


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

* [Bug tree-optimization/42963] [4.5 Regression] Redundant switch labels not cleaned up anymore
  2010-02-04 23:22 [Bug tree-optimization/42963] New: [4,5 Regression] Redundant switch labels not cleaned up anymore steven at gcc dot gnu dot org
  2010-02-05 10:15 ` [Bug tree-optimization/42963] [4.5 " rguenth at gcc dot gnu dot org
  2010-03-19 16:55 ` matz at gcc dot gnu dot org
@ 2010-04-01 13:51 ` steven at gcc dot gnu dot org
  2010-04-06 11:27 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2010-04-01 13:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from steven at gcc dot gnu dot org  2010-04-01 13:51 -------
How is the polishing going?


-- 


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


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

* [Bug tree-optimization/42963] [4.5 Regression] Redundant switch labels not cleaned up anymore
  2010-02-04 23:22 [Bug tree-optimization/42963] New: [4,5 Regression] Redundant switch labels not cleaned up anymore steven at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-04-01 13:51 ` steven at gcc dot gnu dot org
@ 2010-04-06 11:27 ` rguenth at gcc dot gnu dot org
  2010-04-13 21:23 ` [Bug tree-optimization/42963] [4.5/4.6 " steven at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-06 11:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2010-04-06 11:20 -------
GCC 4.5.0 is being released.  Deferring to 4.5.1.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.5.0                       |4.5.1


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


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

* [Bug tree-optimization/42963] [4.5/4.6 Regression] Redundant switch labels not cleaned up anymore
  2010-02-04 23:22 [Bug tree-optimization/42963] New: [4,5 Regression] Redundant switch labels not cleaned up anymore steven at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2010-04-06 11:27 ` rguenth at gcc dot gnu dot org
@ 2010-04-13 21:23 ` steven at gcc dot gnu dot org
  2010-04-14 14:52 ` matz at gcc dot gnu dot org
  2010-04-14 14:53 ` [Bug tree-optimization/42963] [4.5 " matz at gcc dot gnu dot org
  6 siblings, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2010-04-13 21:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from steven at gcc dot gnu dot org  2010-04-13 21:23 -------
Matz, can you at least attach the patch to this PR, so that someone else can
polish it if you're not going to do it?


-- 


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


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

* [Bug tree-optimization/42963] [4.5/4.6 Regression] Redundant switch labels not cleaned up anymore
  2010-02-04 23:22 [Bug tree-optimization/42963] New: [4,5 Regression] Redundant switch labels not cleaned up anymore steven at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2010-04-13 21:23 ` [Bug tree-optimization/42963] [4.5/4.6 " steven at gcc dot gnu dot org
@ 2010-04-14 14:52 ` matz at gcc dot gnu dot org
  2010-04-14 14:53 ` [Bug tree-optimization/42963] [4.5 " matz at gcc dot gnu dot org
  6 siblings, 0 replies; 10+ messages in thread
From: matz at gcc dot gnu dot org @ 2010-04-14 14:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from matz at gcc dot gnu dot org  2010-04-14 14:51 -------
Subject: Bug 42963

Author: matz
Date: Wed Apr 14 14:50:33 2010
New Revision: 158345

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158345
Log:
        PR tree-optimization/42963
        * tree-cfg.c (touched_switch_bbs): New static variable.
        (group_case_labels_stmt): New function broken out from ...
        (group_case_labels): ... here, use the above.
        (start_recording_case_labels): Allocate touched_switch_bbs.
        (end_recording_case_labels): Deallocate it, call
        group_case_labels_stmt.
        (gimple_redirect_edge_and_branch): Remember index of affected BB.

testsuite/
        * testsuite/gcc.dg/pr42963.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/pr42963.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-cfg.c


-- 


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


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

* [Bug tree-optimization/42963] [4.5 Regression] Redundant switch labels not cleaned up anymore
  2010-02-04 23:22 [Bug tree-optimization/42963] New: [4,5 Regression] Redundant switch labels not cleaned up anymore steven at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2010-04-14 14:52 ` matz at gcc dot gnu dot org
@ 2010-04-14 14:53 ` matz at gcc dot gnu dot org
  6 siblings, 0 replies; 10+ messages in thread
From: matz at gcc dot gnu dot org @ 2010-04-14 14:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from matz at gcc dot gnu dot org  2010-04-14 14:53 -------
Fixed for 4.6.  I propose to WONTFIX this for 4.5.


-- 

matz at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|matz at gcc dot gnu dot org |unassigned at gcc dot gnu
                   |                            |dot org
             Status|ASSIGNED                    |NEW
      Known to work|4.4.3                       |4.4.3 4.6.0
            Summary|[4.5/4.6 Regression]        |[4.5 Regression] Redundant
                   |Redundant switch labels not |switch labels not cleaned up
                   |cleaned up anymore          |anymore
   Target Milestone|4.5.1                       |4.6.0


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


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

* [Bug tree-optimization/42963] [4.5 Regression] Redundant switch labels not cleaned up anymore
       [not found] <bug-42963-4@http.gcc.gnu.org/bugzilla/>
  2011-02-25 23:58 ` steven at gcc dot gnu.org
@ 2012-01-16 19:51 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-16 19:51 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WONTFIX                     |FIXED

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-16 19:09:24 UTC ---
.


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

* [Bug tree-optimization/42963] [4.5 Regression] Redundant switch labels not cleaned up anymore
       [not found] <bug-42963-4@http.gcc.gnu.org/bugzilla/>
@ 2011-02-25 23:58 ` steven at gcc dot gnu.org
  2012-01-16 19:51 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu.org @ 2011-02-25 23:58 UTC (permalink / raw)
  To: gcc-bugs

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

Steven Bosscher <steven at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to work|                            |
         Resolution|                            |WONTFIX

--- Comment #8 from Steven Bosscher <steven at gcc dot gnu.org> 2011-02-25 23:17:00 UTC ---
Will not be fixed for GCC 4.5. No need to keep this open.


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

end of thread, other threads:[~2012-01-16 19:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-04 23:22 [Bug tree-optimization/42963] New: [4,5 Regression] Redundant switch labels not cleaned up anymore steven at gcc dot gnu dot org
2010-02-05 10:15 ` [Bug tree-optimization/42963] [4.5 " rguenth at gcc dot gnu dot org
2010-03-19 16:55 ` matz at gcc dot gnu dot org
2010-04-01 13:51 ` steven at gcc dot gnu dot org
2010-04-06 11:27 ` rguenth at gcc dot gnu dot org
2010-04-13 21:23 ` [Bug tree-optimization/42963] [4.5/4.6 " steven at gcc dot gnu dot org
2010-04-14 14:52 ` matz at gcc dot gnu dot org
2010-04-14 14:53 ` [Bug tree-optimization/42963] [4.5 " matz at gcc dot gnu dot org
     [not found] <bug-42963-4@http.gcc.gnu.org/bugzilla/>
2011-02-25 23:58 ` steven at gcc dot gnu.org
2012-01-16 19:51 ` pinskia at gcc dot gnu.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).