[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 21 16:19:26 PDT 2020


yaxunl added a comment.

In D71726#2165494 <https://reviews.llvm.org/D71726#2165494>, @jyknight wrote:

> In D71726#2165445 <https://reviews.llvm.org/D71726#2165445>, @yaxunl wrote:
>
> > In D71726#2165424 <https://reviews.llvm.org/D71726#2165424>, @jyknight wrote:
> >
> > > Why not have clang always emit atomicrmw for floats, and let AtomicExpandPass handle legalizing that into integer atomics if necessary, rather than adding a target hook in clang?
> >
> >
> > Not all targets can legalize fp atomics by AtomicExpandPass. Some targets need library support.
>
>
> That isn't true, because you can do so generically with a cmpxchg loop, assuming that size of atomic is supported by the target. This might not be the most efficient lowering choice, but it's always possible as a fallback. (And if the size is too large, then AtomicExpandPass will lower the cmpxchg to the libatomic call.)
>
> If a target wants to tell AtomicExpandPass that fp add/sub are supported, and then lower the resulting ATOMIC_LOAD_FSUB sdag node into a libcall of its choice, that's also ok (as long as the libcall is lock-free).


how about other fp types e.g. bf16, half, long double? Do we need to diagnose them or not?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71726/new/

https://reviews.llvm.org/D71726





More information about the cfe-commits mailing list