public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Mason <slash.tmp@free.fr>
Cc: gcc-help@gcc.gnu.org, Uros Bizjak <ubizjak@gmail.com>,
	Jeffrey Walton <noloader@gmail.com>,
	Marc Glisse <marc.glisse@inria.fr>
Subject: Re: Use-case for _addcarryx_u64() wrapper
Date: Fri, 2 Jun 2023 14:59:47 +0200	[thread overview]
Message-ID: <ZHnnwzWeHPPYKXrp@tucnak> (raw)
In-Reply-To: <37f1a111-4637-b5aa-41c6-5bda26c99422@free.fr>

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.).

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


  parent reply	other threads:[~2023-06-02 12:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01  7:42 Mason
2023-06-01  8:40 ` Uros Bizjak
2023-06-02 12:45   ` Mason
2023-06-02 12:50     ` Jeffrey Walton
2023-06-03  9:10       ` Mason
2023-06-02 12:59     ` Jakub Jelinek [this message]
2023-06-02 22:53       ` Gabriel Ravier
2023-06-03  8:53         ` Mason
2023-06-03  9:09           ` Jakub Jelinek
2023-06-03 11:37 ` Mason
2023-06-03 11:49   ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZHnnwzWeHPPYKXrp@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=marc.glisse@inria.fr \
    --cc=noloader@gmail.com \
    --cc=slash.tmp@free.fr \
    --cc=ubizjak@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).