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