Though we have the patch https://reviews.llvm.org/D63318 to fold the aext + select in DAGCombine, PowerPC still have own combine rule to do this. However, it didn't handle the any extend well. For now, we will do the zero extend if the select operands are constant and it is fed by any_extend.
t1: i8 = select t0, Constant:i8<-1>, Constant:i8<0> t2: i64 = any_extend t1 --> t3: i64 = select t0, Constant:i64<255>, Constant:i64<0>
The zero extend break the special pattern of "-1" and it might hurt some performance opportunity if they are caring about the sign bit.
This is what we want to do:
t1: i8 = select t0, Constant:i8<-1>, Constant:i8<0> t2: i64 = any_extend t1 --> t3: i64 = select t0, Constant:i64<-1>, Constant:i64<0> --> t4: i64 = sign_extend_inreg t3
This seems like we're working around a problem elsewhere. Why does forcing any_extend to become a sign_extend produce better code than just producing an any_extend?