RFC: clang FP atomic f{minimum, maximum}{,num} builtins (C++26, P3008)

Hi folks,

as part of implementing (P3008) in libc++ (#186716), the atomicrmw instruction now supports fminimum, fmaximum, fminimumnum, and fmaximumnum floating-point operations (and specializations for a few backends will follow). To leverage these from libc++ I’ve opened #187139 to add the following builtins to clang:

  • __atomic_fetch_fminimum
  • __atomic_fetch_fmaximum
  • __atomic_fetch_fminimum_num
  • __atomic_fetch_fmaximum_num
  • (and their __atomic_xxx_fetch and _scoped variants).

These follow the style of the pre-existing __atomic_fetch_min and __atomic_fetch_max builtins, and only differ in the operation names which follow the names of the new operations being introduced (i.e. C++26 std::atomic<float>::fetch_fminimum , C23 fminimum_num, etc.).

@efriedma-quic and @pinskia correctly pointed out in the PR that we should ensure alignment between clang and gcc for these builtins. I’ve asked for feedback/objections in the GCC mailing list (LLVM FP atomic min/max variants alignment) but haven’t received any yet (probably due to the on-going GCC16 release work).

Does anyone have any feedback or any objections to the plan proposed above?

Thanks
Gonzalo

:white_check_mark: This RFC was accepted in this message.

2 Likes

Sorry I miss this (and the corresponding PR)

Are you aware of this previous rfc? ABI for atomic fetch min/max in libatomic

Did you reach out to the author?

I don’t have objections to the name you propose, as long as GCC is fine with them - we certainly want to avoid diverging

Yes to aware and to reaching out.

Thanks.

The Clang Area Team discuss this and we approve the proposed names,

More details [RFC] Builtin names for C++26 atomic reductions (P3111) - #27 by cor3ntin

Thanks