Re: Use-case for _addcarryx_u64() wrapper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/2/23 14:59, Jakub Jelinek via Gcc-help wrote:
On Fri, Jun 02, 2023 at 02:45:40PM +0200, Mason wrote:
On 01/06/2023 10:40, Uros Bizjak wrote:

On Thu, Jun 1, 2023 at 9:42 AM Mason wrote:

As far as I can tell, intrinsics _addcarry_u64() and _addcarryx_u64() are
plain wrappers around the same __builtin_ia32_addcarryx_u64() function.

https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/adxintrin.h

Thus, I wonder: what is the use-case for the wrappers?
Why would a programmer not call the builtin directly?
Is it for compatibility with Intel compilers?
Builtins are internal implementation detail, it is not published API.
Although rarely, builtins can be changed for some reason or another,
while intrinsic functions from adxintrin.h follow published API.
I'm confused.
Built-ins are officially documented:
https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
Sure, some builtins are officially supported.
Those are meant to be used directly by users.

Then there are many builtins which are implementation detail for some
other API that users should use instead.
That includes e.g. builtins used under the hood for <*intrin.h>
implementation - users should use the intrinsics from those headers,
that is documented interface which is supported by multiple compilers,
or builtins used under the hood inside of libstdc++ headers (again,
users should use standard C++ APIs which are supported by multiple
compilers instead of the builtins directly) etc.
E.g. between GCC 3.4 and current trunk 62 __builtin_ia32_* builtins
which were implementation details of the x86 intrinsic headers
have been removed as the intrinsics got implemented some other way
(e.g. using generic vectors etc.).
Does it matter whether or not those builtins are documented ? It seems like most of the __builtin_ia32_ builtins are explicitly documented in the manual, despite the fact that these seem like those you're referring to as being potentially removable at will whenever - and I see no indication in the documentation that they are implementation details/may be removed at any time for any reason.

Some builtins are in both categories, e.g. __atomic_* builtins
are both used in C++ <atomic> APIs, when using C++ one should use those,
or in C <stdatomic.h> APIs, but one can use them directly as well.

	Jakub





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux