If the ~X wasn't able to simplify above the max/min, we might be able to simplify it by moving it below the max/min.
I had to modify the ~(min/max ~X, Y) transform to prevent getting stuck in a loop when we saw the new ~(max/min X, ~Y) before the ~Y had been folded away to remove the new not.
I've left the subtract tests from my previous patch because that's the pattern I want to get optimized. I've added an additional non splat test and dropped the multiple use of the select test since it no longer applied.
The formula suggests that we have a constant, but the code allows for a variable operand. Either the comment should change to match code (C becomes Y) and add a test for that possibility or change the code to match the comment.
Also, we're inverting min/max, so the result in the formula should read (max/min X, ~C)?