[InstCombine] foldICmpBinOp(): consider inverted check in 'unsigned sub overflow' check
A follow-up for r329011.
This may be changed to produce @llvm.sub.with.overflow in a later patch,
but for now just make things more consistent overall.
A few observations stem from this:
- There does not seem to be a similar one-instruction fold for uadd-overflow
- I'm not sure we'll want to canonicalize B u> A as usub.with.overflow, so since the icmp here no longer refers to sub, reconstructing usub.with.overflow will be problematic, and will likely require standalone pass (similar to DivRemPairs).
Name: (A - B) u> A --> B u> A
%t0 = sub i8 %A, %B %r = icmp ugt i8 %t0, %A
%r = icmp ugt i8 %B, %A
Name: (A - B) u<= A --> B u<= A
%t0 = sub i8 %A, %B %r = icmp ule i8 %t0, %A
%r = icmp ule i8 %B, %A
Name: C u< (C - D) --> C u< D
%t0 = sub i8 %C, %D %r = icmp ult i8 %C, %t0
%r = icmp ult i8 %C, %D
Name: C u>= (C - D) --> C u>= D
%t0 = sub i8 %C, %D %r = icmp uge i8 %C, %t0
%r = icmp uge i8 %C, %D