From patchwork Thu Oct 17 22:04:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1998801 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Fts8f+uU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XV2224X4jz1xw2 for ; Fri, 18 Oct 2024 09:04:56 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 893D23858D37 for ; Thu, 17 Oct 2024 22:04:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 43A103858D20 for ; Thu, 17 Oct 2024 22:04:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 43A103858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 43A103858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729202676; cv=none; b=o6FnPcWyU4J9+xxqQmxQXHdkQmr85PWzkMLiEVnyb+5PTwBWEVaveXVsu4KpCmQqmEeksqxY9qO+dk56roT+nf4xqRrsMw5YGI6AvI8vPBPfGCLtN+K/NpRs99t4JI1TKav0AEHFcMwUlT/+kcKy+hIqCJQeIe1aShg3qEFN2vA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729202676; c=relaxed/simple; bh=D26U7VUcyRWneDQ+Zoq/o0Lms6Ja+ux0x/C5chvyubA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=bXPBj+DPxeFSWxKs0f8ZitWXUOc1NUjLeEMjPvphGjkhf3V3N3qT3All/CcDEjUVRv9VQ+M2ShvLuq20/HOZrSzlgvGbIAi3e4q+vF86WT0oy3oYgGuAG8ukIDtmcqm22xpvANDBq9zwMCRXj2L5TByMg82FAU4egjE4tb7F9ds= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729202665; 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: content-transfer-encoding:content-transfer-encoding; bh=bO1UA847zmnonvoGh+fturLvuOrLBxRXeUwazsiNN2E=; b=Fts8f+uUP2n1GFUHQLolRDLDdpQhlC/wcFyKMSA2M7SLsb9MhhPSqIe24JFEVgaF5oOBWL kDexkomgLDWAI0im8N7Mwe6NZafweOFcQPB6X45m6nOiFAD94Cx/yqCAithV6tGk4DB4Eh /473fZW6p4jCgdMzYeShgGTpDk24Ha0= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-442-hhNVkMyBM76PpAbKmOVXPA-1; Thu, 17 Oct 2024 18:04:24 -0400 X-MC-Unique: hhNVkMyBM76PpAbKmOVXPA-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6cbe40565feso2800346d6.1 for ; Thu, 17 Oct 2024 15:04:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729202662; x=1729807462; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bO1UA847zmnonvoGh+fturLvuOrLBxRXeUwazsiNN2E=; b=IpwIsxE+VEpqt05WfE9B6Jrxzlah0lrAHYar8aeryGII8MRbeOpgYqS5XBdJTz01tk jEOe75Q2xoOiB7VKl6iqAr/iCQuE5X5/SMx5wW7AmT7FbIQVnu8H6FSyPyNBCNnb9hCJ 2ODaKBcXMQ+RMovMNEXbsXVBPak3i2KuqD6w/vDZ5leIEjcg13k34v+3kU9CjAer518U 7993I45YQF8WJbcA1Gj/aYI1dgxpU5dRxRuWkR59jBetMnKYPKW9MEMgvCkK260aQSjj ho/lPtQq9tznal9K4hWBJVxVrs6WGj7zbZ6ocLsPaC1xjP8EFszQ6X/zQOl9Xk5Mtapg iYRA== X-Gm-Message-State: AOJu0Yy7+p73FOQf3LA2YaCuWnDnVti8aaH2Ev8OHbp7Zz23QX9/YCHi i2rBIhMfGrxDJdU0xyFv4qYqzgiQuhjCH+U5+0qib1B73/TbPhpGqjPZgIYSQiRwvuiTWEC0PN2 u2gP+ihui0UIi8CWg/7lycRBI8Jj437XLQOep7ccYA9N12IL1/g+dndezIjyQ5mACaUITLDoWRf 2hfJvuVjcOYwGIrk2rUULlI2aL7Tc/M76HUpeJ X-Received: by 2002:a05:622a:5ca:b0:45c:ae15:f630 with SMTP id d75a77b69052e-460aed2bdbemr1792271cf.6.1729202662062; Thu, 17 Oct 2024 15:04:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFQno87qSg/iFKAf5xSCiM1JPDcpBOHerHM6jHxmpGu0vd3/4JDYNHuBrXp8zccoDE9bcm/A== X-Received: by 2002:a05:622a:5ca:b0:45c:ae15:f630 with SMTP id d75a77b69052e-460aed2bdbemr1791971cf.6.1729202661554; Thu, 17 Oct 2024 15:04:21 -0700 (PDT) Received: from localhost.localdomain (ool-18bb2a2e.dyn.optonline.net. [24.187.42.46]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-460ae97199esm931371cf.39.2024.10.17.15.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 15:04:21 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: redundant hashing in register_specialization Date: Thu, 17 Oct 2024 18:04:19 -0400 Message-ID: <20241017220419.443922-1-ppalka@redhat.com> X-Mailer: git-send-email 2.47.0.86.g15030f9556 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.5 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_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? -- >8 -- After r15-4050-g5dad738c1dd164 register_specialization needs to set elt.hash to the (maybe) precomputed hash in order to avoid redundantly rehashing. gcc/cp/ChangeLog: * pt.cc (register_specialization): Set elt.hash. --- gcc/cp/pt.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 8b183a139d7..ec4313090bd 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -1545,9 +1545,7 @@ register_specialization (tree spec, tree tmpl, tree args, bool is_friend, elt.tmpl = tmpl; elt.args = args; elt.spec = spec; - - if (hash == 0) - hash = spec_hasher::hash (&elt); + elt.hash = hash; spec_entry **slot = decl_specializations->find_slot (&elt, INSERT); if (*slot)