This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: basic VRP min/max range overflow question
- From: Robert Dewar <dewar at adacore dot com>
- To: Paul Schlie <schlie at comcast dot net>
- Cc: Michael Veksler <VEKSLER at il dot ibm dot com>, Dale Johannesen <dalej at apple dot com>,GCC Development <gcc at gcc dot gnu dot org>, "Joseph S. Myers" <joseph at codesourcery dot com>,Mike Stump <mrs at apple dot com>, Andrew Pinski <pinskia at physics dot uc dot edu>
- Date: Mon, 20 Jun 2005 09:13:49 -0400
- Subject: Re: basic VRP min/max range overflow question
- References: <BEDC3630.A8DD%schlie@comcast.net>
Paul Schlie wrote:
There don't need to be examples. The as-if rule always applies, if you cannot
write a legitimate C program that shows the difference between two possible
implementations, then both are correct.
??? as-if means they're logically equivalent (i.e. there is no logical
difference between the two alternative representations, and strongly support
that this should be the guideline for all optimizations).
as if means what I said in the above quoted paragraph. I do not know what
"no logical difference" means if it is different from the above criterion.
Note that the requirement of a
legitimate C program exlude ANY program which has undefined behavior anywhere.
Then it is illegitimate for a compiler to generate a program which contains
a known undefined behavior, (i.e. any known overflow, any unsigned to signed
cast which is known to not be representable, any pointer dereference of a
known null value, etc.; rather than generate any code.)
No, that's plain untrue, I don't know how you got that idea.
Expression reordering does not necessitate the violation of sequence point
semantics as long as at the last point of reordering, the resulting
semantics are logically equivalent (as-if); which is why it's a safe
optimization if the logical behavior is preserved.
Again, as-if behavior means that it is not possible to write a correct
C program that distinguishes the cases. No program containing an overflow
can be used for such a test.