public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/96189] New: Failure to use eflags from cmpxchg on x86
@ 2020-07-13 19:44 gabravier at gmail dot com
  2020-07-13 19:55 ` [Bug target/96189] " gabravier at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gabravier at gmail dot com @ 2020-07-13 19:44 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-11-20 15:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-13 19:44 [Bug target/96189] New: Failure to use eflags from cmpxchg on x86 gabravier at gmail dot com
2020-07-13 19:55 ` [Bug target/96189] " gabravier at gmail dot com
2020-07-15  6:41 ` ubizjak at gmail dot com
2020-07-15 20:01 ` ubizjak at gmail dot com
2020-07-15 20:02 ` ubizjak at gmail dot com
2020-07-16  7:05 ` ubizjak at gmail dot com
2020-07-16  7:23 ` rguenther at suse dot de
2020-07-16 18:13 ` cvs-commit at gcc dot gnu.org
2020-11-20 15:12 ` ubizjak at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).