public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/14859] New: [tree-ssa] integrate identical cases of a switch statement.
@ 2004-04-05 22:50 kazu at cs dot umass dot edu
  2004-04-05 23:00 ` [Bug optimization/14859] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-04-05 22:50 UTC (permalink / raw)
  To: gcc-bugs

Consider:

void bar (void);

int
foo (int a)
{
  int b;
  switch (a)
    {
    case 14: b = 123; break;
    case 15: b = 123; break;
    case 16: b = 123; break;
    default: b = 0; break;
    }
  return b;
}

I get:

foo (a)
{
  int b;

<bb 0>:
  switch (a)
    {
      case 14: goto <L0>;
      case 15: goto <L1>;
      case 16: goto <L2>;
      default : goto <L6>;
    }

<L6>:;
  b = 0;
  goto <bb 4> (<L4>);

<L0>:;
  b = 123;
  goto <bb 4> (<L4>);

<L1>:;
  b = 123;
  goto <bb 4> (<L4>);

<L2>:;
  b = 123;

<L4>:;
  return b;

}

If we look at this t54.vars, the problem appears to be fomulated as
cross jumping, but if we look at t51.tailc, the problem appears to be
a simple jump optimization while updating PHI.

foo (a)
{
  int b;

<bb 0>:
  switch (a_2)
    {
      case 14: goto <L0>;
      case 15: goto <L1>;
      case 16: goto <L2>;
      default : goto <L4>;
    }

<L0>:;
  goto <bb 4> (<L4>);

<L1>:;
  goto <bb 4> (<L4>);

<L2>:;

  # b_1 = PHI <0(0), 123(3), 123(2), 123(1)>;
<L4>:;
  return b_1;

}

If cross jumping sounds too machine-dependent, we could limit ourselves
to the PHI-aware jump optimization like above.

-- 
           Summary: [tree-ssa] integrate identical cases of a switch
                    statement.
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Keywords: pessimizes-code
          Severity: enhancement
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


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

end of thread, other threads:[~2004-11-02  1:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-05 22:50 [Bug optimization/14859] New: [tree-ssa] integrate identical cases of a switch statement kazu at cs dot umass dot edu
2004-04-05 23:00 ` [Bug optimization/14859] " pinskia at gcc dot gnu dot org
2004-05-24 21:31 ` [Bug tree-optimization/14859] " pinskia at gcc dot gnu dot org
2004-05-31  6:04 ` pinskia at gcc dot gnu dot org
2004-08-12  1:51 ` pinskia at gcc dot gnu dot org
2004-10-03 21:06 ` pinskia at gcc dot gnu dot org
2004-10-19  4:29 ` pinskia at gcc dot gnu dot org
2004-11-02  1:29 ` pinskia at gcc dot gnu dot org
2004-11-02  1:29 ` pinskia 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).