From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe2f.google.com (mail-vs1-xe2f.google.com [IPv6:2607:f8b0:4864:20::e2f]) by sourceware.org (Postfix) with ESMTPS id 27DEF3858D37 for ; Tue, 21 Mar 2023 11:37:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 27DEF3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cs.washington.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.washington.edu Received: by mail-vs1-xe2f.google.com with SMTP id w20so9367007vsa.8 for ; Tue, 21 Mar 2023 04:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1679398665; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=3Ww5xXoBj2Dxoql24yTMdEznQAbMp1Kz5aBnXiIEJPY=; b=EiiMMjldU6LuC+RDk7tC9pZnBQNFK7d7kdmfbHjw9vf0niWBXxCwlmajccb+oF3BJa LDCBRvL7qwYDeUGAgJNTHlQQl0M8IT3Qdkl0A+KLLwtfGKg3nmKyfk8JvmWsBw/owdp8 2Guhyk80LtVWucCxlUaCFP/f21sUDFu527LCg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679398665; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3Ww5xXoBj2Dxoql24yTMdEznQAbMp1Kz5aBnXiIEJPY=; b=pydXt5sQ+8qXhCcjGtJeOD1edGP0M406AFAofsnEfDcmJ5jMsFeI4xQ++PPzT0gCPq xYg0+5v1N3V4hHqZqXvXqOuiNpPQuJS9zk1blfwrn9s2toh3NwzxJqRauoU9+kVdxFdI ezuYbEC3jM9a63JADpW3ClENO9CtdBL4FMFQEE1QMPrhgSIjbYPGNstRab+bzIU6VUQn W8NkTjkJBqJKy9puHU/GikeN2+MXMIBVOCBNGJqYylxK4j01VoHERDCNRuZ+tOn5sJc9 NmYq93yz+qI2Q8zrrcabLLTbI2oobsLfwNkcXz3NMA4ZPNQ0aSeT7YiC1FWkaguB834C sdyg== X-Gm-Message-State: AO0yUKVBuM3yT8XFq8mEkGUrnAR3qLBo9/OtR5vo8hglgNx/h0qxizYP 9Pb5wK6xZcZSGGJq230ZOj28LdB9wdyisnn3+mdRTw== X-Google-Smtp-Source: AK7set+uAK36+LdIAu7liUgpryQBV5sOOc1C68+caBPHYHNT4evc2R9/yQnPkqIQqJmf6rAoU3qPkhMf5o8IZebdvx0= X-Received: by 2002:a67:cb89:0:b0:425:e5e6:d1d9 with SMTP id h9-20020a67cb89000000b00425e5e6d1d9mr959007vsl.2.1679398665510; Tue, 21 Mar 2023 04:37:45 -0700 (PDT) MIME-Version: 1.0 References: <20230321111056.78121-1-kmatsui@cs.washington.edu> <20230321111056.78121-2-kmatsui@cs.washington.edu> <19d13f2f-65e5-2851-26aa-439ebd90813f@inria.fr> In-Reply-To: From: Ken Matsui Date: Tue, 21 Mar 2023 04:37:34 -0700 Message-ID: Subject: Re: [PATCH 2/2] libstdc++: use new built-in trait __add_const To: Jonathan Wakely Cc: libstdc++@gcc.gnu.org, Marc Glisse , gcc-patches@gcc.gnu.org, ppalka@redhat.com Content-Type: multipart/alternative; boundary="000000000000e4f4c205f767783e" X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000e4f4c205f767783e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=E2=80=AFAM Jonathan Wakely 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 >> > + struct add_const >> > + { using type =3D __add_const(_Tp); }; >> > +#else >> > template >> > struct add_const >> > { using type =3D _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 >> >> --000000000000e4f4c205f767783e--