Consider:

int
foo (int a, int b)
{
  int c = a;
  int d;
  if (a == c)
    d = a;
  else
    d = b;
  return d;
}

Note that "a == c" always holds, so the whole function should collapse
down to return a;.  However, copy-prop on TCB outputs

foo (a, b)
{
  int d;
  int c;
  int D.1137;

<bb 0>:
  c_3 = a_2;
  d_8 = a_2;

  # d_1 = PHI <a_2(0)>;
<L2>:;
  d_4 = d_1;
  return d_1;

}

Note that we are still returning d_1.  Not good.

The problem is that we are not folding COND_EXPR_COND during propagation.

-- 
           Summary: [tcb] missed copy-prop opportunity
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: kazu at cs dot umass dot edu
        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=20762

Reply via email to