Transform vector SET{LE/ULT/ULE} -> SETLT and SET{GE/UGT/UGE} -> SETGT if possible
SETLT and SETGT can use `{v}pcmpgt` directly whereas the other SETCC variants require some other instructions as well. On AVX512, which has vector comparisons for all SETCC variants, this can still be preferable if the destination is a vector. And if the destination is a mask, its the same performance. The transform for unsigned SETCC takes place if we know from `KnownBits` that LHS/RHS have the same sign. The transform for LE/GE -> LT/GT takes place if LHS/RHS is constant and we can inc/dec all elements in the operand without overflowing (both signed and unsigned). Alive2 Links (on i8 so they don't timeout): sge_s: https://alive2.llvm.org/ce/z/rMPt9_ sge_s_2: https://alive2.llvm.org/ce/z/G74Mhs sge_u: https://alive2.llvm.org/ce/z/PTWARM sge_u_2: https://alive2.llvm.org/ce/z/L9dsNn sgt_s: https://alive2.llvm.org/ce/z/q2CHEK sgt_u: https://alive2.llvm.org/ce/z/YPLnZ8 sle_s: https://alive2.llvm.org/ce/z/HyYhQ_ sle_s_2: https://alive2.llvm.org/ce/z/ck6NkT sle_u: https://alive2.llvm.org/ce/z/tyF_wN sle_u_2: https://alive2.llvm.org/ce/z/et8t98 slt_s: https://alive2.llvm.org/ce/z/oCP43b slt_u: https://alive2.llvm.org/ce/z/EpLLPx uge_s: https://alive2.llvm.org/ce/z/rqSDwi uge_s_2: https://alive2.llvm.org/ce/z/67UTXu uge_u: https://alive2.llvm.org/ce/z/yBNG9C uge_u_2: https://alive2.llvm.org/ce/z/UhHYc_ ugt_s: https://alive2.llvm.org/ce/z/tY9va4 ugt_u: https://alive2.llvm.org/ce/z/F9zeAT ule_s: https://alive2.llvm.org/ce/z/1MNgka ule_s_2: https://alive2.llvm.org/ce/z/oiS7Ls ule_u: https://alive2.llvm.org/ce/z/8DveC3 ule_u_2: https://alive2.llvm.org/ce/z/jGp2M7 ult_s: https://alive2.llvm.org/ce/z/chzfwP ult_u: https://alive2.llvm.org/ce/z/Jj_JYu Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D142254
Loading
Please sign in to comment