[Bug optimization/14859] New: [tree-ssa] integrate identical cases of a switch statement.

kazu at cs dot umass dot edu gcc-bugzilla@gcc.gnu.org
Mon Apr 5 22:50:00 GMT 2004


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



More information about the Gcc-bugs mailing list