https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99101
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #4)
> If there are EH edges, doesn't it fit then the -ffinite-loops description:
> '-ffinite-loops'
> Assume that a loop with an exit will eventually take the exit and
> not loop indefinitely. This allows the compiler to remove loops
> that otherwise have no side-effects, not considering eventual
> endless looping as such.
>
> This option is enabled by default at '-O2' for C++ with -std=c++11
> or higher.
> ? EH is an exit as well...
Note the exit isn't an EH edge (sorry for misleading), it's a conditional
controlled exit to noreturn std::__throw_bad_cast ():
<bb 5> [local count: 11633210387]:
comp_md_.at_eof_ = 1;
_14 = std::basic_ostream<char>::operator<< (&cout, 1);
_15 = _14->_vptr.basic_ostream;
_16 = MEM[(long int *)_15 + -24B];
_17 = (sizetype) _16;
_18 = _14 + _17;
_23 = MEM[(const struct __ctype_type * *)_18 + 240B];
if (_23 == 0B)
goto <bb 6>; [0.04%]
else
goto <bb 7>; [99.96%]
<bb 6> [local count: 4653337]:
std::__throw_bad_cast ();
and handling this call first in the post-dom DFS when walking not
reverse reachable blocks makes control dependence behave wrong (or
CD-DCEs expectation is).
Note _not_ treating EH or abnormals as exit makes us more conservative
(we consider the loop to be _not_ finite then).
Again, sorry for misleading.