From patchwork Mon Mar 5 20:31:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 881669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-474299-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="aordT34h"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zwBQ30VwVz9sgM for ; Tue, 6 Mar 2018 07:31:21 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=S0f7QW0lkk5L/1KNSgXEAA3jr+Ivt csnM8Ts/GBQkeRI4jyT6Ky90N8+vNx9Vpt9YCx75vpSy5FqcSIN8pHDZtTHCOGcc ierb/LyekmaBS+ZVJxLkS7XhfEmG8NkNmnT3g/odS/urInDcmIQ77MpQUDPljlrI Da+PH7/i6Nh4CE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=MM1NMruo8OKkQ5LUNIn9hrahHU0=; b=aor dT34hZh/dIPqtM5tWhirv1QY/O8JbcaNDHEZP+vD0Z6VaBkx98dSdKWZkAbl31JT frfVvgqMgt7CGII2SmUWDqWakuanWZjeVFQMb6//BLjbyTdrXmdffp6z9v6qeFaI AZNdQZPDV+nDW9JCVCB5MtJxw4aPQKgrByoEI2jM= Received: (qmail 89229 invoked by alias); 5 Mar 2018 20:31:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 89162 invoked by uid 89); 5 Mar 2018 20:31:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1611, 10339 X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 Mar 2018 20:31:11 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 93158EAE91; Mon, 5 Mar 2018 20:31:06 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-35.brq.redhat.com [10.40.204.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 42B002144B20; Mon, 5 Mar 2018 20:31:06 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w25KV4PB017761; Mon, 5 Mar 2018 21:31:04 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w25KV3gg017760; Mon, 5 Mar 2018 21:31:03 +0100 Date: Mon, 5 Mar 2018 21:31:03 +0100 From: Jakub Jelinek To: Jason Merrill , Nathan Sidwell Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Small performance improvement for constexpr_call_hasher::equal (PR c++/84684) Message-ID: <20180305203103.GQ5867@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) X-IsSubscribed: yes Hi! This doesn't actually fix this PR (Marek is working on that), but just something I've noticed while analyzing the PR. We have the hashes saved in the structure (to speed up hash table expansion), so it is a waste not to test those also in the equal hook, by giving up cheaply in cases of hash table collisions. Additionally, the method returns bool, so this patch uses true/false instead of 1/0. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-03-05 Jakub Jelinek PR c++/84684 * constexpr.c (constexpr_call_hasher::equal): Return false if lhs->hash != rhs->hash. Change return 1 to return true and return 0 to return false. Jakub --- gcc/cp/constexpr.c.jj 2018-03-05 16:11:08.510165108 +0100 +++ gcc/cp/constexpr.c 2018-03-05 16:14:06.130229884 +0100 @@ -1033,9 +1033,11 @@ constexpr_call_hasher::equal (constexpr_ tree lhs_bindings; tree rhs_bindings; if (lhs == rhs) - return 1; + return true; + if (lhs->hash != rhs->hash) + return false; if (!constexpr_fundef_hasher::equal (lhs->fundef, rhs->fundef)) - return 0; + return false; lhs_bindings = lhs->bindings; rhs_bindings = rhs->bindings; while (lhs_bindings != NULL && rhs_bindings != NULL) @@ -1044,7 +1046,7 @@ constexpr_call_hasher::equal (constexpr_ tree rhs_arg = TREE_VALUE (rhs_bindings); gcc_assert (TREE_TYPE (lhs_arg) == TREE_TYPE (rhs_arg)); if (!cp_tree_equal (lhs_arg, rhs_arg)) - return 0; + return false; lhs_bindings = TREE_CHAIN (lhs_bindings); rhs_bindings = TREE_CHAIN (rhs_bindings); }