Use the KnownBits icmp comparisons to determine when a ISD::UMIN/UMAX op is unnecessary should either op be known to be ULE/UGE than the other.
One step at a time :-) The UMIN/UMAX support will help some USUBSAT matching I'm working on, also we don't have test coverage yet and I haven't gotten around to creating SMIN/SMAX tests yet.
I think this check can miss some opportunities because it is slightly asymmetrical. For example, with 4-bit numbers, if LHS = 110x and RHS = x100 then ule(LHS, RHS) will return None. However ult(LHS, RLHS) would return False, so you could optimise to RHS.
It does seem a shame to have to call both ule and ult just to catch this case. I wonder if there is a better way to code it.
Yeah, it seems a shame but we don't have good alternatives - adding the ult/ugt test as well doesn't improve any additional existing tests - I can add coverage if you want though?