From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 7BF073858D37 for ; Tue, 21 Mar 2023 11:25:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7BF073858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679397900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qYdJ2whwqPsbv/+yOO1ZjdxW7WZobYVmV2PU/pALDBg=; b=Rlh5nLNDVa0VZnBf3nsmPK9dZJCVqe6s7KDUYqlSTMm2dtM0YpWpoe5iZXqyYfUT6dCjmR mU3sDkOelZqXfVpa7qA6gDnL9VNlg32CX9/dbUuJVrxmynHetXvUh669KOjTC9R7bWR2pP U0u43jCPsyEEUuIN8ujoxGaYWJnyLlg= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-160-l3yeLM-4N5CLddrYSNd3tg-1; Tue, 21 Mar 2023 07:24:58 -0400 X-MC-Unique: l3yeLM-4N5CLddrYSNd3tg-1 Received: by mail-lf1-f72.google.com with SMTP id z20-20020a195e54000000b004e9609a300cso4348023lfi.2 for ; Tue, 21 Mar 2023 04:24:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679397897; 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=qYdJ2whwqPsbv/+yOO1ZjdxW7WZobYVmV2PU/pALDBg=; b=VTNKhafsFvbbHcpWK5BsA4EMyOCxgwKyE/AKaCfVjqPhf3zdYA627nzNnvc/8b2XUf uuN7PQ/DInpKXBaDvYDJtaDTAXjjfsPCv5HHsW3tvqGlxcIlWBEwiBjLe6uYf03Q6Cnb 7I2imj3GH6Q4GRSwuxvyHxLB+FHveI8j3G9LqgI7UU8jcExYAlLrxKk6NqDfXQ5g0n3b Hj+76kWDtpB7qHYfv3z6anRSLUxh6CuaVY6rL2Gs0OcWuXhsthjb67uGJ1z37fRoOJaL dME3Zkn705vRPDq2rwPxNtuY3u+v301ObUBFCJc5YZ3mRwCXSD4evsTI34y1Penj76W5 mHlA== X-Gm-Message-State: AO0yUKVPxt6Gg60SrBOWuOHkZQcYerolWAzIfJ8jdXD1/KGjyI21J8Op TeqqdfSzZIcL7El3AfFhFasrkmEhJHpRZ7JI75YAWxhEDaNm4ooXGI6DAxXUBI4AToBJ8QNpPol OlQKWgqWq7YkTUkSCLPLFpaGBfft1zvTFDw== X-Received: by 2002:a05:6512:50c:b0:4e9:b146:1fc9 with SMTP id o12-20020a056512050c00b004e9b1461fc9mr676535lfb.8.1679397897103; Tue, 21 Mar 2023 04:24:57 -0700 (PDT) X-Google-Smtp-Source: AK7set+j4qYZwYyC7ljd0y/fn6wU3W+pHlGkkW1wvGON/GmR5tpNNcSlEN3gwT4uULE2Cu61dIZJxTi608t9fA/4kGg= X-Received: by 2002:a05:6512:50c:b0:4e9:b146:1fc9 with SMTP id o12-20020a056512050c00b004e9b1461fc9mr676528lfb.8.1679397896853; Tue, 21 Mar 2023 04:24:56 -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: <19d13f2f-65e5-2851-26aa-439ebd90813f@inria.fr> From: Jonathan Wakely Date: Tue, 21 Mar 2023 11:24:45 +0000 Message-ID: Subject: Re: [PATCH 2/2] libstdc++: use new built-in trait __add_const To: libstdc++@gcc.gnu.org Cc: Ken Matsui , Marc Glisse , gcc-patches@gcc.gnu.org, ppalka@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="000000000000142ec205f7674b0a" X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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: --000000000000142ec205f7674b0a Content-Type: text/plain; charset="UTF-8" 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 = __add_const(_Tp); }; > > +#else > > template > > 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 > > --000000000000142ec205f7674b0a--