JDK-8042786 changes implemented optimization for unsigned integer comparison when one of input is AddI or SubI and its int type can be represented as set of type regions.
This optimization might also be beneficial on some signed comparisons, notably (r1+r2)==0 where r1 and r2 are both [1..maxint].
The problem rise when result of AddI(SubI) may overflow signed integer value.
Let say the input type is [256, maxint] then adding +128 will create 2 ranges due to
overflow: [minint, minint+127] and [384, maxint].
C2 type system keep only 1 type range and as result it use general [minint, maxint] type
for this case which we can't optimize.
Make 2 separate type ranges based on types of AddI(SubI) inputs and compare results of their compare. If results are the same CmpI node can be optimized. Note, only signed equality can be optimized this way.