[LLVMbugs] [Bug 13675] New: [optimization] C++11 std::atomic<>.fetch_or() could be optimized to use 'bts'
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Aug 23 02:36:20 PDT 2012
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: unassignedclangbugs at nondot.org
ReportedBy: mgorny at gentoo.org
CC: llvmbugs at cs.uiuc.edu
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.
More information about the llvm-bugs
mailing list