https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108737
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think this is another case where control dependences do not work as intended.
Marking useful stmt: foo ();
and we have
<bb 2> [local count: 3508266]:
x_4 = foo ();
if (x_4 != 0)
goto <bb 12>; [33.00%]
else
goto <bb 7>; [67.00%]
<bb 12> [local count: 1157728]:
<bb 3> [local count: 116930483]:
<bb 5> [local count: 116930483]:
foo ();
goto <bb 3>; [100.00%]
and BB5 is control dependent on BB3 (on the edge 3->5), so we mark the
block necessary but since there's nothing in it we do not make its
control dependences necessary.
I think what triggers this latent bug is the "double" forwarder with
the call in the latch block rather than in the header when one tries
this on
extern int foo();
void blah()
{
int x = foo();
if (x)
while (1) foo ();
}
it's probably latent with a GIMPLE testcase.