This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix handling of call clobbering readonly-result
Richard Earnshaw wrote:
> The second call to true can be eliminated because true() is a const
> function (has no side-effects) -- put a breakpoint on
> mark_const_function). The compiler has therefore noted that the result of
> the first call can be used in place of the second, and what is more, that
> abort() can never be called from the second point, because if it were, it
> would have been called after the first call.
>
> So I think the compiler has handled this particular example correctly.
Indeed, I noticed this during further investigation. Thanks for clarifying
the case :)
It was a slightly too aggressive evolution of a reduced case which still
shows the difference between the two compilers.
Replace true/false by positive_p/negative_p, both with arguments and the
natural body, and you get the second call to positive_p removed by the new
compiler and not the old one.
Still looking into this.