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 17B82385274E for ; Thu, 9 Jun 2022 15:54:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 17B82385274E 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-333-zQa0k_8xOwqkMQYeRqpJ_A-1; Thu, 09 Jun 2022 11:54:11 -0400 X-MC-Unique: zQa0k_8xOwqkMQYeRqpJ_A-1 Received: by mail-qk1-f197.google.com with SMTP id j12-20020ae9c20c000000b0069e8ac6b244so19330266qkg.1 for ; Thu, 09 Jun 2022 08:54:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=2RRLpOswVoq27ev1ZAnxrLxF9CsIFQexB0dqGE8XM0A=; b=uSqdt5/Fns/7oR+C9dL+MqNDWUdetsoFvM9od092IKIRKVYeIDQukRt1CZM0oXwnYn 3tKmPB1z2pvPtT80UTNGzHgb3XEy2erJLovkLeiPk8Sg6pMaTLrQrQvUkUgBcwrIjd/U fX2kJnC7juWVg/OLFoQ7bHtTQ6146FI8Uo1iNG5AU4mYVoroS86M09dD6vRdcgzIAc1V OGNbdwSmR4cZ2jic5EEjYduw5xI4ls0vjPMhbQ+ML3PXPNwBEesjiNCVMfN7WrGDu0Wg EfEVoQaz8W9MoC1DZFE+OBMGV7kAF/Bgc5v7w5cImOcbgiAslgf/ShUECXhGEVIYyqkR zMXw== X-Gm-Message-State: AOAM5317ibYKl/Hh4IyHGV1+faPMMWo5KamNWe4sqTCqbv8Ix5kngJ/M 1fLvrPc0ha+jSBDPMmOSUuM29USAtdc4sP+EWmUjjsiRRpWt6RCvfqyhnq5kGEGwKla8bk12UMv WRxhj8fgjpBaMwzXt7g== X-Received: by 2002:a05:6214:1bc7:b0:469:e5e5:af88 with SMTP id m7-20020a0562141bc700b00469e5e5af88mr24536468qvc.3.1654790050726; Thu, 09 Jun 2022 08:54:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYvSyHzkFiTQ/ADPWCsSAbJc9NLd6JWBRjLUmui64Wz98mhT0RzUG4N8U2K1t/ey7fqitv7Q== X-Received: by 2002:a05:6214:1bc7:b0:469:e5e5:af88 with SMTP id m7-20020a0562141bc700b00469e5e5af88mr24536448qvc.3.1654790050390; Thu, 09 Jun 2022 08:54:10 -0700 (PDT) Received: from [192.168.1.100] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id a16-20020a05620a439000b006a715ca69d9sm3088695qkp.136.2022.06.09.08.54.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Jun 2022 08:54:09 -0700 (PDT) Message-ID: <012da98c-ff3b-69d8-2d17-346ad2818049@redhat.com> Date: Thu, 9 Jun 2022 11:54:08 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH 2/1] c++: optimize specialization of templated member functions To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20220608182147.4123587-1-ppalka@redhat.com> <20220609130013.250243-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20220609130013.250243-1-ppalka@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jun 2022 15:54:14 -0000 On 6/9/22 09:00, Patrick Palka wrote: > This performs one of the optimizations added by the previous > patch to lookup_template_class, to instantiate_template as well. > (For the libstdc++ ranges tests this optimization appears to be > effective around 30% of the time, i.e. 30% of the time context of 'tmpl' > is non-dependent while the context of 'gen_tmpl' is dependent.) If this is a significant optimization, how about doing it in tsubst_aggr_type rather than its callers? > gcc/cp/ChangeLog: > > * pt.cc (instantiate_template): Don't substitute the context > of the most general template if that of the partially > instantiated template is non-dependent. > --- > gcc/cp/pt.cc | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > index e021c254872..208daad298a 100644 > --- a/gcc/cp/pt.cc > +++ b/gcc/cp/pt.cc > @@ -21661,8 +21661,14 @@ instantiate_template (tree tmpl, tree orig_args, tsubst_flags_t complain) > ++processing_template_decl; > if (DECL_CLASS_SCOPE_P (gen_tmpl)) > { > - tree ctx = tsubst_aggr_type (DECL_CONTEXT (gen_tmpl), targ_ptr, > - complain, gen_tmpl, true); > + tree ctx; > + if (!uses_template_parms (DECL_CONTEXT (tmpl))) > + /* If the context of the partially instantiated template is already > + non-dependent, then we might as well use it. */ > + ctx = DECL_CONTEXT (tmpl); > + else > + ctx = tsubst_aggr_type (DECL_CONTEXT (gen_tmpl), targ_ptr, > + complain, gen_tmpl, true); > push_nested_class (ctx); > } >