<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - 64-bit atomic_load"
   href="https://bugs.llvm.org/show_bug.cgi?id=38515">38515</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>64-bit atomic_load
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>nruslan_devel@yahoo.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I have noticed that clang/llvm generates atomic_load (64-bit) for i686+ as
cmpxchg8b, whereas gcc avoids it by using FPU instructions.

#include <stdatomic.h>


unsigned long long func(_Atomic(unsigned long long) *a)
{
        return atomic_load(a);
}

clang -Wall -O2 -m32 -S test.c


clang/llvm:

func:                                   # @func
# %bb.0:
        pushl   %ebx
        pushl   %esi
        movl    12(%esp), %esi
        xorl    %eax, %eax
        xorl    %edx, %edx
        xorl    %ecx, %ecx
        xorl    %ebx, %ebx
        lock            cmpxchg8b       (%esi)
        popl    %esi
        popl    %ebx
        retl
.Lfunc_end0:


whereas gcc generates:

func:
.LFB0:
        .cfi_startproc
        subl    $12, %esp
        .cfi_def_cfa_offset 16
        movl    16(%esp), %eax
        fildq   (%eax)
        fistpq  (%esp)
        movl    (%esp), %eax
        movl    4(%esp), %edx
        addl    $12, %esp
        .cfi_def_cfa_offset 4
        ret</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>