If x has multiple sign bits than it doesn't matter which one we extend from so we can sext from x's msb instead.
The X86 setcc-combine.ll changes are a little weird, but probably not much of a performance difference. It appears we ended up with a (sext_inreg (aext (trunc (extractelt)))) after type legalization. The sext_inreg+aext now gets optimized by this combine to leave (sext (trunc (extractelt))). Then we visit the trunc before we visit the sext. This ends up changing the truncate to an extractvectorelt from a bitcasted vector. I can see a couple ways to fix this. Early exit from visitTRUNCATE if its used by a sext similar to what is done for aext. This is tricky because we aren't always able to optimize a sext+trunc. The other option is to change type legalization to promote extractvectorelt inputs and result type simultaneously. If we promote the result first we can temporarily have an extractvectorelt with a result type we never really wanted.