public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ken Matsui <kmatsui@cs.washington.edu>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: libstdc++@gcc.gnu.org, 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 04:37:34 -0700	[thread overview]
Message-ID: <CAML+3pXNyGe5k-vh4pqyEmswwXNjME0qp3TXwuNe=WcxKAxbCA@mail.gmail.com> (raw)
In-Reply-To: <CACb0b4nQUtzSjkRv1ZdNBFTX-CiWh28si8epSpbxY03TV9wxOQ@mail.gmail.com>

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

Thank you for your information. Although it matches my intuition, I sent
this patch because I was unsure my intuition was correct. As Jonathan
pointed out, there appear to be several implementation errors. The
benchmark result for this trait is kind of trivial, so I will implement the
other traits I want to implement and then come back here.

Thank you all for your help.

On Tue, Mar 21, 2023 at 4:25 AM Jonathan Wakely <jwakely@redhat.com> wrote:

>
>
> 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:37 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
2023-03-21 11:37       ` Ken Matsui [this message]
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='CAML+3pXNyGe5k-vh4pqyEmswwXNjME0qp3TXwuNe=WcxKAxbCA@mail.gmail.com' \
    --to=kmatsui@cs.washington.edu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --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).