[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
Thu May 21 14:39:15 PDT 2020


yaxunl marked 3 inline comments as done.
yaxunl added inline comments.


================
Comment at: clang/include/clang/Basic/TargetInfo.h:1418
+  /// Whether floating point atomic fetch add/sub is supported.
+  virtual bool isFPAtomicFetchAddSubSupported() const { return false; }
+
----------------
tra wrote:
> I think it should be predicated on specific type.
> E.g. NVPTX supports atomic ops on fp32 ~everywhere, but fp64 atomic add/sub is only supported on newer GPUs.
> And then there's fp16...
will do and add tests for fp16


================
Comment at: clang/test/CodeGen/atomic-ops.c:296
+  // CHECK: fsub
+  return __atomic_sub_fetch(p, 1.0, memory_order_relaxed);
+}
----------------
ldionne wrote:
> yaxunl wrote:
> > ldionne wrote:
> > > Sorry if that's a dumb question, but I'm a bit confused: `p` is  a `float*`, but then we add a double `1.0` to it. Is that intended, or should that be `double *p` instead (or `1.0f`)?
> > In this case, the value type is converted to the pointee type of the pointer operand.
> Ok, thanks for the clarification. Yeah, it was a dumb question after all. I still think it should be made clearer by using `1.0f`.
this test has been removed. the new tests do not have this issue.


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

https://reviews.llvm.org/D71726





More information about the cfe-commits mailing list