https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110891

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
One thing I noticed (I don't know if causes the missed optimization) is that we
have before PRE:
```
  <bb 4> [local count: 1073531371]:
  if (a.0_1 != 0)
    goto <bb 6>; [50.00%]
  else
    goto <bb 5>; [50.00%]

  <bb 5> [local count: 536765686]:
  if (_28 == &d)
    goto <bb 9>; [30.00%]
  else
    goto <bb 7>; [70.00%]

  <bb 6> [local count: 536765685]:
  if (_28 == &d)
    goto <bb 9>; [30.00%]
  else
    goto <bb 7>; [70.00%]
```
Which obvious should just be `if (_28 == &d) goto bb9; else goto bb7;` and not
check `a.0_1` at all.

I tried a reduced testcase but PRE optimizes it:
```
int g();
int h();

int j, l;

int f(int a, int *b)
{
        if (a == 0)
        {
                if (b == &j) goto L9; else goto L7;
        }
        else
        {
                if (b == &j) goto L9; else goto L7;
        }
L7: return g();
L9: return h();
}
```

Reply via email to