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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #21 from Richard Biener <rguenth at gcc dot gnu.org> ---
So I'm somewhat lost in pointing to the actual error.  And I'm not sure there
is any error, just unfortuate optimization behavior in the face of the testcase
being undefined with -ffinite-loops (or in C++).

That said, more "sensible" optimization from the undefined behavior would
have been to exit the loop, not preserving the if (xx) test.  With preserving
it we either end up with infinite puts() or no puts() calls both which
have the "wrong" number of invocations of the side-effect in the loop.

There's still the intuitively missing control dependence on the if (at_eof)
check (which is also missing without -ffinite-loops but doesn't cause any
wrong DCE there).  But as said my gut feeling is that control dependence
doesn't capture the number of invocations but only whether something is
invoked.  That's likely why we manually add control dependences of the
latch of loops for possibly infinite loops.

CCing Honza who added the control-dependence stuff and who may remember
some extra details.

Reply via email to