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: "joseph at codesourcery 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:54:13 +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 #16 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Fri, 24 Nov 2017, maxim.yegorushkin at gmail dot com wrote:
> > It's valid to call a function in another file compiled with another
> > compiler that follows the ABI, or compiled with -fwrapv, or not written in
> > C at all.
>
> That amounts to saying that the extra test instruction should only be emitted
> when compiling with -fwrapv. Is that right?
No. It's valid for a function compiled without -fwrapv to call one
compiled with -fwrapv. After such a call, the value of OF is unknown.
That is, there is no need for any undefined behavior for OF to be set
after a function call, and there is no need for any undefined behavior for
OF to be set on function entry, and a function cannot know whether its
caller or callees were compiled in ways that allow them to set OF. It's
*also* perfectly valid for code with no undefined behavior and no -fwrapv
to set OF if an instruction that happens to set OF happens to be the most
convenient way of implementing that code's semantics.