[Bug target/83133] Superflous x86 test instructions in generated assembly.

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Nov 24 17:20:00 GMT 2017


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

--- Comment #9 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Maxim Egorushkin from comment #6)

> This code underflows a signed integer, which is undefined behaviour, if I am
> not mistaken. So, this would not be a valid example, would it?

An example of "dangerous optimization" from Comment #2 was requested. The
optimization is valid, but this code happens as well. As shown in the example,
the program, compiled with clang declared 2147483647 as nonpositive when
compiled with -O2 and as positive when compiled with -O0.

We can sweep the issue under the carpet as "undefined behaviour", but I don't
want to jeopardize the robustness of an industrial-strength compiler with the
implementation of this relatively minor optimization.


More information about the Gcc-bugs mailing list