This is a common idiom which arises after induction variables are widened, and we have two or more exit conditions.
Reviewers, my commented reasoning is sound right? This seems pretty basic, and nothing I can find in LLVM handles this pattern. Am I missing something?
The implementation of IsKnownPredicateViaMinOrMax() canonicalizes ICMP_SGE/ICMP_UGE by swapping (and isKnownPredicateViaNoOverflow() does as well), so I would suggest including it here as well.
It doesn't matter for the min/max case as both orders are tried there, but generally this code doesn't seem to assume a particular predicate canonicalization.