From patchwork Fri Mar 20 14:06:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 452650 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 032731401AF for ; Sat, 21 Mar 2015 01:08:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=MtHU9QZ7; dkim-adsp=none (unprotected policy); 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=XowAgeZfi3jqOjZf7 FxhmCdTAEn5FRJ0EXDrdKmzE8htYysMJXrxEws4jMTvs/ZqI76PWlmIKn+Ss/2X3 Ez24HYatW/PMTPxISu1Cnf67ZTt9g5nfH2CxMZQjYC26hHSKD3SE6dvpMBmWz8Fr ITGYPCA2ECx/VurdfCWfcicCXE= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=BF0hjWcT5yUBJPwnsVNgb+K VFAY=; b=MtHU9QZ7Mp6BnrCmJ1S42xjvPoda5Ux1KkVnT5VeTRCQMqei+767KQL 0u7X2D8sdoOiM0XdtfDofXZEJcNYZww7RdPB557qa04Fvdj6QHSeXfvWdllL4MxC Dult0l2bzg0oTmKObF1wKT09xaC/xAGYTINlt3ELS9FqsQPtJBoY= Received: (qmail 30784 invoked by alias); 20 Mar 2015 14:07:36 -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 30597 invoked by uid 89); 20 Mar 2015 14:07:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 20 Mar 2015 14:07:31 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B5898AD6A; Fri, 20 Mar 2015 14:06:25 +0000 (UTC) Message-ID: <550C2961.1090009@suse.cz> Date: Fri, 20 Mar 2015 15:06:25 +0100 From: =?UTF-8?B?TWFydGluIExpxaFrYQ==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Jakub Jelinek CC: gcc-patches@gcc.gnu.org, Jan Hubicka Subject: Re: [PATCH] Speed-up def_builtin_const (ix86_valid_target_attribute) References: <54FE1B94.9080208@suse.cz> <20150313044257.GB55012@kam.mff.cuni.cz> <550B3DDC.4030408@suse.cz> <20150320000959.GC48586@kam.mff.cuni.cz> <550BF765.2070705@suse.cz> <20150320112452.GD1746@tucnak.redhat.com> In-Reply-To: <20150320112452.GD1746@tucnak.redhat.com> X-IsSubscribed: yes On 03/20/2015 12:24 PM, Jakub Jelinek wrote: > On Fri, Mar 20, 2015 at 11:33:09AM +0100, Martin Liška wrote: >> @@ -30670,6 +30673,20 @@ def_builtin_const (HOST_WIDE_INT mask, const char *name, >> static void >> ix86_add_new_builtins (HOST_WIDE_INT isa) >> { >> + /* Last cached isa value. */ >> + static HOST_WIDE_INT last_tested_isa_value = 0; >> + >> + /* We iterate through all defined builtins just if the last tested >> + values is different from ISA and just in case there is any intersection >> + between ISA value and union of all possible configurations. >> + Last condition skips iterations if ISA is changed by the change has >> + empty intersection with defined_isa_values. */ >> + if ((isa & defined_isa_values) == 0 || isa == last_tested_isa_value >> + || ((isa ^ last_tested_isa_value) & defined_isa_values) == 0) >> + return; >> + >> + last_tested_isa_value = isa; > > Isn't at least the isa == last_tested_isa_value test useless? > I mean, if they are equal, then (isa ^ last_tested_isa_value) is 0 > and so the third test is true. > > Also, given that the loop does something only for > (ix86_builtins_isa[i].isa & isa) != 0 > it means once you call ix86_add_new_builtins with some particular > bit set in the isa, it doesn't make sense to try that bit again. > > So, I think it would be better: > 1) rename defined_isa_values bitmask to say deferred_isa_values > (as in, isa bits that might still enable any new builtins) > 2) in def_builtin, don't or in the mask unconditionally, but only > in the else case - when add_builtin_function is not called > 3) in ix86_add_new_builtins, don't add last_tested_isa_value at all, instead > do: > if ((isa & deferred_isa_values) == 0) > return; > > deferred_isa_values &= ~isa; > > That way, when you actually enable all builtins (either immediately in > def_builtin because it wasn't C/C++-like FE, or because all ISAs were > enabled from the start, or because ix86_add_new_builtins has been already > called with sufficiently full bitmask), deferred_isa_values will be 0 and > you won't do anything in the function any more. > > Jakub > Thank you Jakub for smart solution. I've just implemented new patch, which I've been testing. What do you think about it? Martin From 3469163018d3c8ad2849bb9d241e12ae8723da90 Mon Sep 17 00:00:00 2001 From: mliska Date: Fri, 20 Mar 2015 14:51:47 +0100 Subject: [PATCH] Speed-up def_builtin_const (ix86_valid_target_attribute). gcc/ChangeLog: 2015-03-20 Martin Liska Jakub Jelinek * config/i386/i386.c (def_builtin): Set deferred_isa_values for masks that can potentially include a builtin. (ix86_add_new_builtins): Introduce fast filter for isa values that cannot trigger builtin inclusion. --- gcc/config/i386/i386.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 47deda7..82a4848 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -30588,6 +30588,8 @@ struct builtin_isa { static struct builtin_isa ix86_builtins_isa[(int) IX86_BUILTIN_MAX]; +/* Bits that can still enable any inclusion of a builtin. */ +static HOST_WIDE_INT deferred_isa_values = 0; /* Add an ix86 target builtin function with CODE, NAME and TYPE. Save the MASK of which isa_flags to use in the ix86_builtins_isa array. Stores the @@ -30631,6 +30633,9 @@ def_builtin (HOST_WIDE_INT mask, const char *name, } else { + /* Just a MASK where set_and_not_built_p == true can potentially + include a builtin. */ + deferred_isa_values |= mask; ix86_builtins[(int) code] = NULL_TREE; ix86_builtins_isa[(int) code].tcode = tcode; ix86_builtins_isa[(int) code].name = name; @@ -30666,6 +30671,12 @@ def_builtin_const (HOST_WIDE_INT mask, const char *name, static void ix86_add_new_builtins (HOST_WIDE_INT isa) { + if ((isa & deferred_isa_values) == 0) + return; + + /* Bits in ISA value can be removed from potential isa values. */ + deferred_isa_values &= ~isa; + int i; tree saved_current_target_pragma = current_target_pragma; current_target_pragma = NULL_TREE; -- 2.1.2