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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
What is interesting is that the call to foo is still there on the gimple level
in GCC 11, it is only on the RTL level it is able to be removed ....

What I see missing on the gimple level on the trunk is a jump threading
opportunity (but might be too complex to do):
  <bb 8> [local count: 12528922893]:
  # c.3_16 = PHI <0(4), 2(7)>
  _9 = h;
  _10 = *_9;
  _11 = *_10;
  _12 = *_11;
  if (_12 <= 4)
    goto <bb 10>; [50.00%]
  else
    goto <bb 9>; [50.00%]

...

  <bb 10> [local count: 6264461501]:
  _15 = d;
  *_10 = _15;
  if (c.3_16 == 0)
    goto <bb 11>; [5.50%]
  else
    goto <bb 12>; [94.50%]

  <bb 12> [local count: 5919916023]:
  if (a.11_30 != 0)
    goto <bb 13>; [33.00%]
  else
    goto <bb 9>; [67.00%]

The threading is:
4->8->10->11
7->8->10->12

This requires copying bb 8 and 10. I am not saying it is the right thing to do
but rather that is how to optimize this out I think.


There is also this one too:
  <bb 3> [local count: 12528922784]:
  # a.11_30 = PHI <_18(14), -28(2)>
  c.0_3 = c;
  if (a.11_30 != 0)
    goto <bb 4>; [5.50%]
  else
    goto <bb 5>; [94.50%]


2->3->4
14->3

But as I said I have not looked into more than that.

Reply via email to