https://bugs.llvm.org/show_bug.cgi?id=43658
Bug ID: 43658
Summary: Improve codegen for std::midpoint
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedb...@nondot.org
Reporter: david.bolvan...@gmail.com
CC: craig.top...@gmail.com, llvm-bugs@lists.llvm.org,
llvm-...@redking.me.uk, spatel+l...@rotateright.com
When one argument is a known constant value, gcc produces better code.
int foo(int a) {
return std::midpoint(a,100);
}
Clang trunk -O3
foo(int): # @foo(int)
cmp edi, 100
mov ecx, 100
mov eax, edi
cmovg eax, ecx
cmp edi, 99
cmovg ecx, edi
sub ecx, eax
shr ecx
mov eax, ecx
neg eax
cmp edi, 100
cmovle eax, ecx
add eax, edi
ret
Block RThroughput: 2.7
GCC -O3
foo(int):
mov edx, 100
cmp edi, 101
mov eax, edx
cmovl edx, edi
setl cl
cmovge eax, edi
movzx ecx, cl
lea ecx, [rcx-1+rcx]
sub eax, edx
shr eax
imul eax, ecx
add eax, edi
ret
Block RThroughput: 2.5
https://godbolt.org/z/F6PE2w
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs