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.129.124]) by sourceware.org (Postfix) with ESMTPS id 8E6B83850233 for ; Wed, 7 Sep 2022 08:01:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8E6B83850233 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=1662537670; 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=99GsXUvu6I35ipfuheKiE0ShuX9dFhC2P8H8wg8fS6U=; b=faClZgWCwSv8duJxDfSJnXopGJSQH2rY85cCEV1Izc0UwHYIkD3eUk6xaN8yNgBaRA68Z6 Njfj7yeBO1wrl/C0hvgm2y4YdjGbKMAVMopp+b1Waa7exZ+KtvWjQxa3kmEzdvcCk4FFDy UYbXPear6vyEQ0xaEeaDNZbmrybDFNU= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-647-7ImmE9JCOr-ICt_YE4pMIQ-1; Wed, 07 Sep 2022 04:01:09 -0400 X-MC-Unique: 7ImmE9JCOr-ICt_YE4pMIQ-1 Received: by mail-qk1-f197.google.com with SMTP id bs43-20020a05620a472b00b006bb56276c94so11348366qkb.10 for ; Wed, 07 Sep 2022 01:01:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=99GsXUvu6I35ipfuheKiE0ShuX9dFhC2P8H8wg8fS6U=; b=z9In4738trQhtCCuXY6F2v0hp810q9KMqkmRPoT1yWx4nGTAYZ8xBhBfxiFvDd3YiL dEA9xz97KdaMinRp3uM15/JQZrmDA25lvxEzFsWAokCjUvu/np7pRxZWsf2VarS2VrZv VcNxl4yRsVcnIjRMj58XPqmcFPrgDaGbEIl+ldhxh+KWO/UZxXNmXaS7W1fTkHhup3e4 B7OXabZR5mDPeOKf4VDyqdOOrAFOaFmRraqz2acO7CHInof0S8OVZliDeDmdNMh3jHZ0 BEDa7aCNtaha3cMg1OKkvVafJiPkE7p25yuhqOJuo35T+w2GOD/jXux9hukr4h9UpvTC rCvQ== X-Gm-Message-State: ACgBeo0mhtoz7JJoBkTIAVMXLUZBEx188FQG3b0ov9l3mBP6zqcjWClo oRWWvUPnWKTfM9ffIMbl6nCs8d12/Ps7hAo6ZuyvYY2O5iIXa4hHUW/cyDDlveWOt8mlDrDEY0W 4FJe8LkmD0OBw0R1F68+Lon3JVxDnLAQ= X-Received: by 2002:ac8:5b15:0:b0:343:6789:193a with SMTP id m21-20020ac85b15000000b003436789193amr2047151qtw.647.1662537668889; Wed, 07 Sep 2022 01:01:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Xorfo+TDCburOBo5Z022KOE5NAW7kFSrI9LVjdT/hmDL7/gr96xMOD3zg2ppx1oxazZA6Uf9b2C19fG8ar4g= X-Received: by 2002:ac8:5b15:0:b0:343:6789:193a with SMTP id m21-20020ac85b15000000b003436789193amr2047136qtw.647.1662537668684; Wed, 07 Sep 2022 01:01:08 -0700 (PDT) MIME-Version: 1.0 References: <20220907004542.288365-1-ppalka@redhat.com> <20220907004542.288365-2-ppalka@redhat.com> In-Reply-To: <20220907004542.288365-2-ppalka@redhat.com> From: Jonathan Wakely Date: Wed, 7 Sep 2022 09:00:57 +0100 Message-ID: Subject: Re: [PATCH 2/2] libstdc++: Optimize is_reference To: Patrick Palka Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 7 Sept 2022 at 01:46, Patrick Palka via Libstdc++ wrote: > > Instead of defining is_reference in terms of is_lvalue_reference > and is_rvalue_reference, just define it directly. > > Tested on x86_64-pc-linux-gnu, does this look OK for trunk? Yes, thanks (I already did this for the std::is_reference_v variable template, but for some reason left this equivalent change in the local branch where I was doing the traits refactoring). > This reduces memory usage of join.cc by 1%. Now that many of the variable templates have been optimized to avoid instantiating class templates, I wonder if the code (and anything else that's only defined for C++17 or later) would benefit from using foo_v && bar_v instead of __and_, bar>. With your improvements to __and_ maybe it doesn't make so much difference. > > libstdc++-v3/ChangeLog: > > * include/std/type_traits (is_reference): Make the primary > template derive from false_type. Define two partial > specializations that derive from true_type. > --- > libstdc++-v3/include/std/type_traits | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits > index b83e7257a9f..94e73eafd2f 100644 > --- a/libstdc++-v3/include/std/type_traits > +++ b/libstdc++-v3/include/std/type_traits > @@ -611,8 +611,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > /// is_reference > template > struct is_reference > - : public __or_, > - is_rvalue_reference<_Tp>>::type > + : public false_type > + { }; > + > + template > + struct is_reference<_Tp&> > + : public true_type > + { }; > + > + template > + struct is_reference<_Tp&&> > + : public true_type > { }; > > /// is_arithmetic > -- > 2.37.3.518.g79f2338b37 >