This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Document arithmetic overflow semantics
- From: Roger Sayle <roger at www dot eyesopen dot com>
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Cc: gcc-patches at gcc dot gnu dot org, <gcc at gcc dot gnu dot org>
- Date: Thu, 13 Feb 2003 11:16:03 -0700 (MST)
- Subject: Re: [PATCH] Document arithmetic overflow semantics
> > I'm prepared to drop this entire argument if you can find me just one
>
> The one I mentioned: (a*2)/2.
That'll do. You're right, GCC does optimize this assuming undefined
overflow. Good to my word, I hereby withdraw my patch. There are
more bugs in this area, than I can hope to address.
Interestingly, Microsoft's Visual C/C++ compilers don't optimize this
example. I wonder how much of their 20% SPECint advantage over mainline
GCC is from their use of two's-complement semantics vs. undefined
overflow. For example, they also optimize "z1 = (x+y)+z; z2 = x+(y+z)"
which GCC currently can't.
What can I say. I tried. I failed.
My apologies for any inconvenience.
Roger
--