This is the mail archive of the gcc@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]

Re: -fwrapv enables some optimizations


On Wed, 20 Dec 2006, Bruno Haible wrote:

> But the other way around? Without -fwrapv the compiler can assume more
> about the program being compiled (namely that signed integer overflows
> don't occur), and therefore has more freedom for optimizations. All
> optimizations that are possible with -fwrapv should also be performed
> without -fwrapv. Anything else is a missed optimization.

Indeed.  Fixing this may require it to be possible to mark individual 
operations with their overflow semantics (which will also be needed for 
LTO to handling inlining between translation units compiled with different 
options).  The problem is that some optimizations involve transforming an 
"overflow undefined" operation into an "overflow wraps" one, which is a 
valid transformation, but can't be represented in trees at present - but 
when the transformation is also valid for the initial operation being an 
"overflow wraps" one, the optimization can be done if -fwrapv.

When individual operations can be so marked, the optimizations in question 
can then be done if the original operation is either "overflow undefined" 
or "overflow wraps".

-- 
Joseph S. Myers
joseph@codesourcery.com


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