This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: signed int performance question
- From: Andrew Haley <aph at redhat dot com>
- To: Eyal Itkin <eyal dot itkin at gmail dot com>, gcc at gcc dot gnu dot org
- Date: Tue, 28 Feb 2017 09:43:00 +0000
- Subject: Re: signed int performance question
- Authentication-results: sourceware.org; auth=none
- References: <CAA=iMUJeaig309F7kkVOT+7DgsAuV7VPv_suVDEN2+Drzd=44g@mail.gmail.com>
On 28/02/17 06:38, Eyal Itkin wrote:
> However, in signed integers, the logical meaning of any relation check
> is only the theoretical meaning of the order relation between the
> numbers in the group Z. Meaning that in a purely theoretical manner "a
> + b < c" is a relation order that is equivalent to "a < c - b" or even
> " 0 < c - b - a". The only exception here is about any possible
> integer overflow (above MAX_INT) or underflow (below MIN_INT), however
> such cases are specified to be undefined in the C standard, and should
> not harm the possible efficiency of the code generation.
We can't change arithmetic which does not overflow into arithmetic
which might. We re-order operations where we know that it's safe
to do so, but this one does not look safe to me.
Andrew.