Jay Foad <[email protected]> writes:
>From an optimisation pass's point of view, what's the difference between:
>
> 1. a PLUS expression that gives an undefined result on overflow, and
> 2. a PLUS expression with a guarantee that the result won't overflow.
>
> I can't see how they will be handled any differently in practice.
I don't think that's the right way to describe the alternatives. The
choices are:
1. A PLUS expression which gives an undefined result on overflow;
2. A PLUS expression which wraps on overflow.
Those two cases can be optimized differently. For example,
(a +undef-overflow C1) < C2
where C1 and C2 are constants, may be optimized to
a < C2 - C1
That is not true of
(a +wrapping-overflow C1) < C2
Ian