<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/68602>68602</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang] builtin `__cxx_atomic_fetch_add` should support all floating point types
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            bug,
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          huixie90
      </td>
    </tr>
</table>

<pre>
    This issues came up in implementing P0020R6 Floating Point Atomic for libc++
https://github.com/llvm/llvm-project/pull/67799

Basically we are trying to use `__cxx_atomic_fetch_add` for implementing atomic RMW operations. However, this function would error on some platforms for `long double` if the representation is x87 fp80 format. On the library (libc++) side, there is no way for us to tell if the function `__cxx_atomic_fetch_add` is going to error on the current platform or not.

The builtin should handle this properly: generates FADD IR for platforms that support it, and fallback to the compare-exchange loop on the platforms that don't
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlE-r4zYUxT-NvLlMUJT438KLvAmhXZSWx0CXQZavbbXXktCfSfLti-VJ5rWLB4UQY1u695zf1bEMQU8GsWPlGyvPhUxxtr6bk75rbHnR2-HRfZt1AB1CwgBKLgjJgTagF0e4oInaTPAH54K_V3AhK7cHVpsIp2gXrWC0Hkj3iom39cfPjJ_mGF1ghxMTFyYuk45z6nfKLkxciL4_L1-ct3-hikxcXCJi4lLVddtuJbb_Nxm0kkQPuCFIjxD9Y1UQLaSAwCp-var7_SqzluuIUc1XOQys4lnYv3xsi-D9tz_BOvQyamvCDn6xN_yOnomvEFcaYzJqfQU3m2gA9N56sAaCXRAcyThav4RcnlWcrJlgsKknXJvqEeKM4NF5DGhibgI6wL2pYXRNlrXIuIPfTV5JuvfSP4CJ5gNF0ULQA26a0ONawVi4yUfum8JKICLRs-FL9KdIdIDJ_uD38rVuV8l7NPFlD6wHY-Pu4yy-zQh90hS1gTBnNrM0A-GGzfkVKj3Y4QQTmpUvBriczmf49T2r_skuzjJCSM5ZH0HH1aY0A4ySqJfq72xuVWUXJz1-wbuapZkQyFr3lPyfaoM1TNSxGLrD0B5aWWC3r9qqqaq6PhZzNzSDwuFYlbwvR3Ucjrxqqn2t9nul-rLCQneCi8Oe83ZflqI87uoDin5_KOsR-6aWih05LlLTbj27O-unIuemq5qKi4JkjxRy1oTo08SEYOIrE0KRNPmuPBe-y-e-T1NgR046xPCzWtSRcli3HeX5RfvTmf4YxZOmJILxGVSXgxofDkORPHX_O5fbl2FN5mrynwAAAP__dP92Aw">