Bug 20762 - [tcb] missed copy-prop opportunity
Summary: [tcb] missed copy-prop opportunity
Status: RESOLVED DUPLICATE of bug 20913
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: unknown
: P2 enhancement
Target Milestone: ---
Assignee: Kazu Hirata
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2005-04-04 22:45 UTC by Kazu Hirata
Modified: 2005-04-12 23:13 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-04-05 23:26:25


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kazu Hirata 2005-04-04 22:45:35 UTC
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.
Comment 1 Andrew Pinski 2005-04-05 23:26:25 UTC
Confirmed.
Comment 2 Kazu Hirata 2005-04-12 23:13:51 UTC
PR20913 has a better testcase.


*** This bug has been marked as a duplicate of 20913 ***