[Bug target/96189] New: Failure to use eflags from cmpxchg on x86
gabravier at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jul 13 19:44:23 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96189
Bug ID: 96189
Summary: Failure to use eflags from cmpxchg on x86
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
bool f(unsigned char* addr, unsigned char old_val, unsigned char new_val)
{
auto old_val_cpy = old_val;
__atomic_compare_exchange_n(addr, &old_val, new_val, 0, 0, 0);
return old_val == old_val_cpy;
}
With -O3, LLVM outputs this :
f(unsigned char*, unsigned char, unsigned char): # @f(unsigned char*, unsigned
char, unsigned char)
mov eax, esi
lock cmpxchg byte ptr [rdi], dl
sete al
ret
GCC outputs this :
f(unsigned char*, unsigned char, unsigned char):
mov eax, esi
movzx edx, dl
lock cmpxchg BYTE PTR [rdi], dl
cmp al, sil
sete al
ret
GCC could use the EFLAGS generated from cmpxchg, but it does not.
More information about the Gcc-bugs
mailing list