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: GCC optimizes integer overflow: bug or feature?


On Tue, 19 Dec 2006, Ian Lance Taylor wrote:
> Here is a quick list of optimizations that mainline gcc performs which
> rely on the idea that signed overflow is undefined.  All the types
> are, of course, signed.  I made have made some mistakes.  I think this
> gives a good feel for the sorts of optimizations we can make with this
> assumption.

Thanks for compiling this exhaustive list, Ian!

Currently our documentation on -fwrapv is rather short and does not
provide examples or anything to provide such a feel:

  This option instructs the compiler to assume that signed arithmetic 
  overflow of addition, subtraction and multiplication wraps around
  using twos-complement representation.  This flag enables some 
  optimizations and disables others.  This option is enabled by default 
  for the Java front-end, as required by the Java language specification.

"This flag enables some optimizations and disables others" is all we
have.  I wonder whether you could perhaps add (part of) your list to
this documentation?  Or would that be too specific?

Gerald


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