This patch adds a context-aware analysis that tris to prove that (Op, LHS, RHS) does
not overflow. The basic version of this algorithm takes wide type which is 2x wider
than the original type and tries to prove that ext(LHS + RHS) == ext(LHS) + ext(RHS),
and the context-aware analysis only works with constants and their ranges.
This one adds the following logic: we compute three values:
- B = ext(LHS) + ext(RHS);
- min = ext(MIN_VALUE) (i.e. min value of LHS's original type);
- max = ext(MAX_VALUE) (i.e. max value of LHS's original type);
And if we can prove that in the given context min <= B <= max, then the computation
was without overflow (i.e. result is still in bounds in terms of original type).
There is one regression with IV widening, but this transform has long been known
for being unstable and awkwardly broken, and it needs to be fixed separately.
In most cases it allows us to infer more no-wrap flags.
Arguably regression