From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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, 05 Mar 2018 20:31:00 -0000 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-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00235.txt.bz2 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. --- 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); } Jakub