From patchwork Thu May 4 14:43:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 758597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wJd800J7mz9s2Q for ; Fri, 5 May 2017 00:43:59 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="XjH0xXhf"; dkim-atps=neutral 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=VzNnVX6d23VdizvoM/vuKLBEPBfcu If9eaY4+WHoDnEc/BfTnwpCX0nHnqbK/dTkneF/xrZoQyv+lm+AL0zeJfp4LZEFg ZKJVvHWgclSh8uk7ataVA+dInkxoXqqD1v4UtW15jGajfdIMVZ9GDQws5nNQ0VKM PJBDCSjgXCXaUg= 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=8/WA4oSV4iSMqwoyHLtzLbsUIvA=; b=XjH 0xXhfmYSBQmwl+ILIfKM6deHHB59vNORPeN4x8khkKFqBp+OMgIJSIp3BGWRO3Gf Ka4Aon+gjMYbP1VQFiNk1WDc+x7+xZeo1bmf/Stg/79qklXLgLie0DHsN1LIAFVk aiZ7zrdW/G98sOsgQVmA9z871MjO5zbFnUPNDv28= Received: (qmail 98633 invoked by alias); 4 May 2017 14:43:49 -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 98619 invoked by uid 89); 4 May 2017 14:43:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1816, waste X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 May 2017 14:43:47 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 037B23D971; Thu, 4 May 2017 14:43:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 037B23D971 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 037B23D971 Received: from tucnak.zalov.cz (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E7F862926; Thu, 4 May 2017 14:43:48 +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 v44EhkR4021127; Thu, 4 May 2017 16:43:46 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v44EhjLe021126; Thu, 4 May 2017 16:43:45 +0200 Date: Thu, 4 May 2017 16:43:45 +0200 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Small type_hash_canon improvement Message-ID: <20170504144345.GS1809@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes Hi! While type_hash_canon in case of reusing an already existing type ggc_frees the freshly created type, we still waste one type uid for each such case, this patch attempts to avoid that. Furthermore, for INTEGER_TYPE we keep around the min and max value INTEGER_CSTs and the cached values vector (until it is GCed). Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-05-04 Jakub Jelinek * tree.c (next_type_uid): Change type to unsigned. (type_hash_canon): Decrement back next_type_uid if freeing a type node with the highest TYPE_UID. For INTEGER_TYPEs also ggc_free TYPE_MIN_VALUE, TYPE_MAX_VALUE and TYPE_CACHED_VALUES if possible. Jakub --- gcc/tree.c.jj 2017-05-03 16:55:39.688052581 +0200 +++ gcc/tree.c 2017-05-03 18:49:30.662185944 +0200 @@ -151,7 +151,7 @@ static const char * const tree_node_kind /* Unique id for next decl created. */ static GTY(()) int next_decl_uid; /* Unique id for next type created. */ -static GTY(()) int next_type_uid = 1; +static GTY(()) unsigned next_type_uid = 1; /* Unique id for next debug decl created. Use negative numbers, to catch erroneous uses. */ static GTY(()) int next_debug_decl_uid; @@ -7188,6 +7188,19 @@ type_hash_canon (unsigned int hashcode, { tree t1 = ((type_hash *) *loc)->type; gcc_assert (TYPE_MAIN_VARIANT (t1) == t1); + if (TYPE_UID (type) + 1 == next_type_uid) + --next_type_uid; + if (TREE_CODE (type) == INTEGER_TYPE) + { + if (TYPE_MIN_VALUE (type) + && TREE_TYPE (TYPE_MIN_VALUE (type)) == type) + ggc_free (TYPE_MIN_VALUE (type)); + if (TYPE_MAX_VALUE (type) + && TREE_TYPE (TYPE_MAX_VALUE (type)) == type) + ggc_free (TYPE_MAX_VALUE (type)); + if (TYPE_CACHED_VALUES_P (type)) + ggc_free (TYPE_CACHED_VALUES (type)); + } free_node (type); return t1; }