[llvm-bugs] [Bug 46707] New: Failure to use al for sete after cmpxchg

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 13 09:26:31 PDT 2020


            Bug ID: 46707
           Summary: Failure to use al for sete after cmpxchg
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: gabravier at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

int 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):
  mov eax, esi
  xor ecx, ecx
  lock cmpxchg byte ptr [rdi], dl
  sete cl
  mov eax, ecx

Is there some weird hardware problem that makes the sete slower if used on al
or something ? If not, I see no reason why the sete could not have al as the
operand, which would avoid the mov afterwards.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200713/5f76263f/attachment.html>

More information about the llvm-bugs mailing list