This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]