This is round 2 of D68643. The values were not being sign extended or zero extended correctly, which could lead to incorrect results when the incoming values were not already extended. They are needed because the min/max need no superfluous values in the higher bits.
I've fixed that and added some extra tests. Not everything here is an improvement (although most of it still is). Some of the i4 cases look slightly larger, but this may be improved in cases where the extend can become free (from a load, for example).