IRCE for unsigned latch conditions was temporarily disabled by rL314881. The motivating
example contained an unsigned latch condition and a signed range check. One of the safe
iteration ranges was [1, SINT_MAX + 1]. Its right border was incorrectly interpreted as a negative
value in IntersectRange function, this lead to a miscompile under which we deleted a range check
without inserting a postloop where it was needed.
This patch brings back IRCE for unsigned latch conditions. Now we treat range intersection more
carefully. If the latch condition was unsigned, we only try to consider a range check for deletion if:
- The range check is also unsigned, or
- Safe iteration range of the range check lies within [0, SINT_MAX].
The same is done for signed latch.
Values from [0, SINT_MAX] are unambiguous, these values are non-negative under any interpretation,
and all values of a range intersected with such range are also non-negative.
We also use signed/unsigned min/max functions for range intersection depending on type of the
latch condition.