ValueTracking was recognizing not all variations of clamp. Swapping of
true value and false value of select was added to fix this problem. This
change breaks the canonical form of cmp inside the matchMinMax function,
that is why additional checks for compare predicates is needed. Added
corresponding test cases.
Also there is a reverse transformation for cmp instruction:
icmp smin(x, PositiveValue), 0 -> icmp x, 0
We should only do this after checking for min/max to prevent infinite
looping caused by a reverse canonicalization of these patterns. That is
why this transformation was moved to place after the mentioned check.
Test case was also added to check that we don't go to infinite loop.