This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Document arithmetic overflow semantics
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: jbuck at synopsys dot com
- Cc: gcc-patches at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Date: Thu, 13 Feb 03 11:06:39 EST
- Subject: Re: [PATCH] Document arithmetic overflow semantics
In C, it is frequently the case that defining the overflow behavior of
signed integer in this way makes more optimizations possible. For one
thing, it makes addition and multiplication associative. Without such
an assumption, you can't turn (a+b)+c into a+(b+c), because the overflows
might be different.
True, but there are an equal number of simplification that can only be done
if you are allowed to assume that overflow is undefined.
Perhaps an approach might be to say that "we know what overflow
actually does for this operation, but if it occurs, it's undefined
semantics". That's what we actually *implement* right now and would
give the best of both worlds. Then there would be a bit that says that,
in this particular operation, the overflow is *not* undefined.