This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/83133] Superflous x86 test instructions in generated assembly.
- From: "maxim.yegorushkin at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 24 Nov 2017 17:28:32 +0000
- Subject: [Bug target/83133] Superflous x86 test instructions in generated assembly.
- Auto-submitted: auto-generated
- References: <bug-83133-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83133
--- Comment #13 from Maxim Egorushkin <maxim.yegorushkin at gmail dot com> ---
(In reply to Uroš Bizjak from comment #9)
> (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.
It looks like -fstrict-overflow flag is there to enable exactly this kind of
optimization.