Bug 42635 - no-op conversions hinder if-conversion
Summary: no-op conversions hinder if-conversion
Status: RESOLVED DUPLICATE of bug 51030
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.5.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2010-01-06 15:16 UTC by Richard Biener
Modified: 2012-01-23 23:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
testcase using vec.h (6.80 KB, text/plain)
2010-01-06 15:17 UTC, Richard Biener
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2010-01-06 15:16:26 UTC
The following two functions are not if-converted at the tree level (the 2nd
example happens a lot from VEC code via VEC_BASE):

int *bar (char *p)
{
  int *q;
  if (p)
    q = (int *)p;
  else
    q = (int *)0;
  return q;
}

struct X { int q; };
int *foo (struct X *p)
{
  int *q;
  if (p)
    q = &p->q;
  else
    q = (int *)0;
  return q;
}

before phiopt1 we have

bar (char * p)
{
  int * q;

<bb 2>:
  if (p_2(D) != 0B)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  q_3 = (int *) p_2(D);

<bb 4>:
  # q_1 = PHI <q_3(3), 0B(2)>
  return q_1;

which can be optimized to just

<bb 2>:
  return (int *) p_2(D);

well - with a separate stmt for the conversion.
Comment 1 Richard Biener 2010-01-06 15:17:17 UTC
Created attachment 19485 [details]
testcase using vec.h
Comment 2 Andrew Pinski 2012-01-23 23:44:11 UTC
Both are handled correctly already.
PR 51030 for foo.
bar was fix in 4.6.0.

I am just going to mark this as a dup of bug 51030.

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