[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GCC optimizes integer overflow: bug or feature?
From: |
Joe Buck |
Subject: |
Re: GCC optimizes integer overflow: bug or feature? |
Date: |
Tue, 19 Dec 2006 13:21:02 -0800 |
User-agent: |
Mutt/1.4.1i |
On Tue, Dec 19, 2006 at 12:05:44PM -0800, 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.
There are two different sets of cases: those where gcc's behavior is
consistent with the assumption that signed overflow wraps, and those
that are not consistent with that assumption. For all common targets,
the signed integer instructions actually do wrap, and the result is that
when people compile without optimization, this is what they observe,
and what they unconsciously assume.
For example:
> * Fold ((A + C1) cmp C2) to (A cmp (C1 + C2)) where C1 and C2 are
> constants, and likewise for -.
If cmp is == or !=, this are consistent with the assumption that overflow
wraps. For <, <=, >, >= it is not.
For that reason, it might be more appropriate to warn about cases where
gcc might do an optimization that is *not* consistent with the "wrap"
assumption. Otherwise there will be way too much noise.
- avoid integer overflow in mktime.m4, Ralf Wildenhues, 2006/12/18
- Re: avoid integer overflow in mktime.m4, Paul Eggert, 2006/12/18
- GCC optimizes integer overflow: bug or feature? (was: avoid integer overflow in mktime.m4), Ralf Wildenhues, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Paul Eggert, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Paul Eggert, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Joseph S. Myers, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Paul Eggert, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Gabriel Dos Reis, 2006/12/19
- Re: [bug-gnulib] GCC optimizes integer overflow: bug or feature?, Bruno Haible, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Ian Lance Taylor, 2006/12/20
- Re: GCC optimizes integer overflow: bug or feature?,
Joe Buck <=
- Re: GCC optimizes integer overflow: bug or feature? (was: avoid integer overflow in mktime.m4), Andrew Pinski, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Brooks Moses, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Robert Dewar, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Andrew Haley, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Robert Dewar, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Andrew Pinski, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Robert Dewar, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Florian Weimer, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Paolo Bonzini, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Florian Weimer, 2006/12/19