http://llvm.org/bugs/show_bug.cgi?id=13675
Bug #: 13675
Summary: [optimization] C++11 std::atomic<>.fetch_or() could be
optimized to use 'bts'
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Classification: Unclassified
$ clang --version
clang version 3.2 (trunk) (04622b05755fb9dbb062735a53e779e1deb29a97)
Target: x86_64-pc-linux-gnu
Thread model: posix
The minimal test case:
#include <atomic>
int main()
{
std::atomic_int foo;
return foo.fetch_or(1);
}
Results in the following assembly (-O3 -S):
# BB#0:
movl $1, %ecx
.LBB0_1: # =>This Inner Loop Header: Depth=1
movl -8(%rsp), %eax
movl %eax, %edx
orl %ecx, %edx
lock
cmpxchgl %edx, -8(%rsp)
jne .LBB0_1
# BB#2:
ret
I believe that such an operation (atomic bit-setting) could be done much easier
and faster using the 'bts' (bit test & set) mnemonic.
I'm not sure if this can be enhanced in clang, llvm or whether it needs changes
to libstdc++.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs