[X86] Improve select of constants
Without this patch: %cmp = icmp eq i32 %a, %b %cond = select i1 %cmp, i32 1, i32 2 is compiled as: 31 c9 xor %ecx,%ecx 39 f7 cmp %esi,%edi 0f 94 c1 sete %cl b8 02 00 00 00 mov $0x2,%eax 29 c8 sub %ecx,%eax With this patch, the compiler generates: 31 c0 xor %eax,%eax 39 f7 cmp %esi,%edi 0f 95 c0 setne %al ff c0 inc %eax saving 5 bytes while reducing register usage. This patch transforms C - setcc into inverted_setcc + (C-1) if C is a nonzero constant. This patch fixes: https://github.com/llvm/llvm-project/issues/60854 Differential Revision: https://reviews.llvm.org/D144449
Loading
Please sign in to comment