This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Simplification of relational expressions
- From: Andrew Haley <aph at redhat dot com>
- To: John Fine <johnsfine at verizon dot net>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 04 Jun 2008 12:54:58 +0100
- Subject: Re: Simplification of relational expressions
- References: <87lk1lvqki.fsf@cse.unl.edu> <48467D96.3050504@verizon.net>
John Fine wrote:
> Andrew Haley wrote:
>> Chris Thiel wrote
>>> Is there a reason that the equality and inequality expressions (and only
>>> those expressions) are simplified? I understand that signed integer
>>> overflow is undefined.
>> I'm more than a little mystified by this question. Unless the target is
>> using something truly weird like saturating arithmetic we can always
>> guarantee that a+1 != a, but we cannot guarantee that a+1 > a.
> The optimizer is always allowed to know the behaviors that result in
> THIS compiler from undefined behavior. If the optimizer can predict the
> run time answer with complete certainty, it can use that answer.
Yes.
> You could create a compiler with saturating arithmetic, so the most
> positive integer plus one is still the most positive integer. Then the
> optimizer of THAT compiler could safely assume a+1 >= a but couldn't
> assume a+1>a nor a+1!=a.
Yes.
> But for THIS compiler the most positive integer plus one is the most
> negative integer. The compiler knows that even though the standard
> doesn't know it and a well written program shouldn't know it. So THIS
> compiler can assume a+1!=a.
Which it is doing. What, then, is your point?
Andrew.