[Bug c++/94649] New: 16-byte aligned atomic_compare_exchange doesn not generate cmpxcg16b on x86_64
avi@cloudius-systems.com
gcc-bugzilla@gcc.gnu.org
Sat Apr 18 18:17:38 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94649
Bug ID: 94649
Summary: 16-byte aligned atomic_compare_exchange doesn not
generate cmpxcg16b on x86_64
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: avi@cloudius-systems.com
Target Milestone: ---
The code
#include <atomic>
struct alignas(16) a {
long x;
long y;
};
bool cmpxchg(std::atomic<a>& data, a expected, a newval) {
return std::atomic_compare_exchange_weak(&data, &expected, newval);
}
compiles with -O3 -mcx16 generates a "lock cmpxchg16b" instruction with clang,
but not with gcc, where it generates a library call to
__atomic_compare_exchange_16. This is a missed optimization.
More information about the Gcc-bugs
mailing list