<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 - target attribute "cx16" is ignored"
   href="https://bugs.llvm.org/show_bug.cgi?id=45651">45651</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>target attribute "cx16" is ignored
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>myriachan@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Compile the following with -O2 on x86_64:

__attribute__((__target__("cx16")))
void write128(_Atomic(__int128)* p, __int128 v)
{
    __c11_atomic_store(p, v, __ATOMIC_SEQ_CST);
}

That generates:

<source>:4:5: warning: large atomic operation may incur significant performance
penalty [-Watomic-alignment]
    __c11_atomic_store(p, v, __ATOMIC_SEQ_CST);
    ^
1 warning generated.

_Z8write128Pnn: # @_Z8write128Pnn
  sub rsp, 24
  mov rax, rdi
  mov qword ptr [rsp + 8], rdx
  mov qword ptr [rsp], rsi
  mov rdx, rsp
  mov edi, 16
  mov rsi, rax
  mov ecx, 5
  call __atomic_store
  add rsp, 24
  ret

If you add -mcx16 to the command line, Clang generates the intended code:

_Z8write128Pnn: # @_Z8write128Pnn
  push rbx
  mov rcx, rdx
  mov rbx, rsi
  mov rax, qword ptr [rdi]
  mov rdx, qword ptr [rdi + 8]
.LBB0_1: # =>This Inner Loop Header: Depth=1
  lock cmpxchg16b xmmword ptr [rdi]
  jne .LBB0_1
  pop rbx
  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>