[LLVMbugs] [Bug 19164] New: __sync_fetch_and_or with power-of-two argument should generate "lock bts" code

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 17 10:48:47 PDT 2014


            Bug ID: 19164
           Summary: __sync_fetch_and_or with power-of-two argument should
                    generate "lock bts" code
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: hans at chromium.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


unsigned f(unsigned *addr) {
  return __sync_fetch_and_or(addr, 1 << 7) & (1 << 7);

We currently generate:

        movl    (%rdi), %eax
        movl    $128, %ecx
        orl     %eax, %ecx
        cmpxchgl        %ecx, (%rdi)
        jne     .LBB0_1
        andl    $128, %eax

It would be cool if we could recognize that the read-modify-write we're doing
here is actually bit-test-and-set, which can be done with the bts instruction.

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/20140317/2183ac32/attachment.html>

More information about the llvm-bugs mailing list