public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org
Cc: Ken Matsui <kmatsui@cs.washington.edu>,
	Marc Glisse <marc.glisse@inria.fr>,
	 gcc-patches@gcc.gnu.org, ppalka@redhat.com
Subject: Re: [PATCH 2/2] libstdc++: use new built-in trait __add_const
Date: Tue, 21 Mar 2023 11:24:45 +0000	[thread overview]
Message-ID: <CACb0b4nQUtzSjkRv1ZdNBFTX-CiWh28si8epSpbxY03TV9wxOQ@mail.gmail.com> (raw)
In-Reply-To: <19d13f2f-65e5-2851-26aa-439ebd90813f@inria.fr>

[-- Attachment #1: Type: text/plain, Size: 1329 bytes --]

On Tue, 21 Mar 2023 at 11:21, Marc Glisse via Libstdc++ <
libstdc++@gcc.gnu.org> wrote:

> On Tue, 21 Mar 2023, Ken Matsui via Libstdc++ wrote:
>
> >   /// add_const
> > +#if __has_builtin(__add_const)
> > +  template<typename _Tp>
> > +    struct add_const
> > +    { using type = __add_const(_Tp); };
> > +#else
> >   template<typename _Tp>
> >     struct add_const
> >     { using type = _Tp const; };
> > +#endif
>
> Is that really better? You asked elsewhere if you should measure for each
> patch, and I think that at least for such a trivial case, you need to
> demonstrate that there is a point. The drawbacks are obvious: more code in
> libstdc++, non-standard, and more builtins in the compiler.
>

Right, this one isn't even getting rid of any partial specializations, but
it is giving the preprocessor more work to do.

Adding the extra built-ins to the compiler makes the compiler (very
slightly) bigger and slower, so a real benchmark would require comparing an
unpatched gcc (without the new built-in) to a patched gcc and patched
libstdc++ sources.



>
> Using builtins makes more sense for complicated traits where you can save
> several instantiations. Now that you have done a couple simple cases to
> see how it works, I think you should concentrate on the more complicated
> cases.
>
> --
> Marc Glisse
>
>

  reply	other threads:[~2023-03-21 11:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21 11:10 [PATCH 1/2] c++: implement __add_const built-in trait Ken Matsui
2023-03-21 11:10 ` [PATCH 2/2] libstdc++: use new built-in trait __add_const Ken Matsui
2023-03-21 11:20   ` Marc Glisse
2023-03-21 11:24     ` Jonathan Wakely [this message]
2023-03-21 11:37       ` Ken Matsui
2023-03-21 11:26 ` [PATCH 1/2] c++: implement __add_const built-in trait Jonathan Wakely
2023-03-21 11:29   ` Jonathan Wakely

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=CACb0b4nQUtzSjkRv1ZdNBFTX-CiWh28si8epSpbxY03TV9wxOQ@mail.gmail.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kmatsui@cs.washington.edu \
    --cc=libstdc++@gcc.gnu.org \
    --cc=marc.glisse@inria.fr \
    --cc=ppalka@redhat.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).