Re: Simplification of relational expressions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux