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 55C983858C41 for ; Thu, 18 May 2023 18:54:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 55C983858C41 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=1684436093; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1aPMi/znBMB63BjqaB/PzxfajR3YqylZNMJN5uTdzc4=; b=InJcYSMTceCMnsdkLH4qZv4hXeEdA5ZceB/a0f7lyNjSOtB5aF4eAaAk26uVwUqMO+6bQv PByyeVKysQUzhysFadPFQPmbtfuUhkwB2ddkEZeFzUYewmWBXFrvt4Y2pRXhPGY+uXSLmd dhk3xo+vWVlTr0GlQyNT1pBmUKy5LGU= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-V6jjm2sNMUmtQFCMxWYG1Q-1; Thu, 18 May 2023 14:54:52 -0400 X-MC-Unique: V6jjm2sNMUmtQFCMxWYG1Q-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-3f687cd5971so8691311cf.2 for ; Thu, 18 May 2023 11:54:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684436092; x=1687028092; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1aPMi/znBMB63BjqaB/PzxfajR3YqylZNMJN5uTdzc4=; b=JYzYeyMt2i48JK63zSBls0WXjH6gZDllJb9n5JfknS8k5KALC56OmdU5maEQSIy99V a4KP3V3NT5yGNVvCPWCh8RPp37Rg9Mzy0LOWyzuLoYHLsnDwqnOQvnFm1oUULJmAhLTJ 3SarBGQ7Vq4RLryMgtsSI7hdvxF541DKTGPJilC+/kHe5rjd/MuGjQeY0RYzIKEYYilN z2Zp3p4adikf8eJdntRza6zeVHd+Xc0jxO7Jxd+8MQF4/3Xw2TkYdf+DGSO/pJbMZc38 9fK38YA0x3Io7MWSgte4ZZWrtrrYmzBdjJnJ7t6MwQLgAXWj25oBD1QLOoM/vI3cVIEC bYDA== X-Gm-Message-State: AC+VfDwYWG6qrfC5gcApf4DoW6TPWrchsifMFfHYb38ni+VOlPB0mD4P umEPAVDdbz3G02nJPKG12MOGIHFcy8FOLmzomlbhNRO/IEFVArwLAIBak/m7Jj7sFXRCvIdDY7C imStZEjI+R7UKS3M939jXIsNSBg== X-Received: by 2002:ac8:5c4b:0:b0:3f3:9204:f9e0 with SMTP id j11-20020ac85c4b000000b003f39204f9e0mr1556095qtj.16.1684436091854; Thu, 18 May 2023 11:54:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7C2MrT7XXq3eTCglxpYjf/6gcfzNQWVUhez1lNwQ4ym/cgnjenVlli4lgsSb5Uq7t5/QzX6Q== X-Received: by 2002:ac8:5c4b:0:b0:3f3:9204:f9e0 with SMTP id j11-20020ac85c4b000000b003f39204f9e0mr1556066qtj.16.1684436091561; Thu, 18 May 2023 11:54:51 -0700 (PDT) Received: from [192.168.1.108] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id m9-20020ac807c9000000b003f4ed0ca698sm701582qth.49.2023.05.18.11.54.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 May 2023 11:54:50 -0700 (PDT) Message-ID: <1994ab2b-71a9-fe0f-6956-47a584cef509@redhat.com> Date: Thu, 18 May 2023 14:54:50 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] c++: simplify norm_cache manipulation To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20230518180114.4158415-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20230518180114.4158415-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=-14.1 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 List-Id: On 5/18/23 14:01, Patrick Palka wrote: > Avoid performing two norm_cache lookups during normalization of a > concept-id by allocating inserting a norm_entry* before rather than > after the fact, which is simpler and faster. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk? OK. > gcc/cp/ChangeLog: > > * constraint.cc (normalize_concept_check): Avoid having to do > two norm_cache lookups. Remove unnecessary early exit for an > ill-formed concept definition. > --- > gcc/cp/constraint.cc | 31 +++++++++---------------------- > 1 file changed, 9 insertions(+), 22 deletions(-) > > diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc > index c81e024e0e2..8cf0f2d0974 100644 > --- a/gcc/cp/constraint.cc > +++ b/gcc/cp/constraint.cc > @@ -774,38 +774,25 @@ normalize_concept_check (tree check, tree args, norm_info info) > > if (!norm_cache) > norm_cache = hash_table::create_ggc (31); > - norm_entry entry = {tmpl, targs, NULL_TREE}; > - norm_entry **slot = nullptr; > - hashval_t hash = 0; > - bool insert = false; > + norm_entry *entry = nullptr; > if (!info.generate_diagnostics ()) > { > /* Cache the normal form of the substituted concept-id (when not > diagnosing). */ > - hash = norm_hasher::hash (&entry); > - slot = norm_cache->find_slot_with_hash (&entry, hash, NO_INSERT); > - if (slot) > + norm_entry elt = {tmpl, targs, NULL_TREE}; > + norm_entry **slot = norm_cache->find_slot (&elt, INSERT); > + if (*slot) > return (*slot)->norm; > - insert = true; > + entry = ggc_alloc (); > + *entry = elt; > + *slot = entry; > } > > - /* The concept may have been ill-formed. */ > tree def = get_concept_definition (DECL_TEMPLATE_RESULT (tmpl)); > - if (def == error_mark_node) > - return error_mark_node; > - > info.update_context (check, args); > tree norm = normalize_expression (def, targs, info); > - if (insert) > - { > - /* Recompute SLOT since norm_cache may have been expanded during > - the recursive call. */ > - slot = norm_cache->find_slot_with_hash (&entry, hash, INSERT); > - gcc_checking_assert (!*slot); > - entry.norm = norm; > - *slot = ggc_alloc (); > - **slot = entry; > - } > + if (entry) > + entry->norm = norm; > return norm; > } >