[all-commits] [llvm/llvm-project] 1e552d: [X86] Improve select of constants
kazutakahirata via All-commits
all-commits at lists.llvm.org
Tue Feb 28 15:04:08 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1e552d0c5bf1627b92ac205cab07d3e09d911750
https://github.com/llvm/llvm-project/commit/1e552d0c5bf1627b92ac205cab07d3e09d911750
Author: Kazu Hirata <kazu at google.com>
Date: 2023-02-28 (Tue, 28 Feb 2023)
Changed paths:
M llvm/lib/Target/X86/X86ISelLowering.cpp
M llvm/test/CodeGen/X86/select-constant-xor.ll
M llvm/test/CodeGen/X86/select_const.ll
Log Message:
-----------
[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
More information about the All-commits
mailing list