From patchwork Thu Mar 19 21:21:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 452274 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 181AD1400EA for ; Fri, 20 Mar 2015 08:21:47 +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=BT/Hi8S5; 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=IvbF/rSPAQO+U98LO WvttLTsovXLdeuSFet/Ek1QmaZFwiK623xews8fcHQu242QnzxnlS6XWL/ivtW88 zPpjX9Y/vVCFZXUUORqiqsy83m5z/jf9jdCpkb2NcNJ2/RyR9cR5HErBT0CmoemP +tw/tZrGL5cb84aVMkvaPSh8Kw= 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=i8+DQimOasmpshx+eWT+mBa P51c=; b=BT/Hi8S5Zjtk2kcDN9uxLyqPvSU/N5XuMFl0sL6HH2S9cFSyZi50/KO JsyNR5+wk00Sauz0e6NAlcOlGuwneDqdoXrELlEBqCErJlOnXw/V//KqouTIz42P Gk/1+jyA+UUpRNIcYjC1/SAwYMILpWr0h+Qh8oICW0lbToHWj04w= Received: (qmail 119160 invoked by alias); 19 Mar 2015 21:21:39 -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 119148 invoked by uid 89); 19 Mar 2015 21:21:38 -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; Thu, 19 Mar 2015 21:21:37 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4CBBCABF1; Thu, 19 Mar 2015 21:21:34 +0000 (UTC) Message-ID: <550B3DDC.4030408@suse.cz> Date: Thu, 19 Mar 2015 22:21:32 +0100 From: =?windows-1252?Q?Martin_Li=9Aka?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: 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> In-Reply-To: <20150313044257.GB55012@kam.mff.cuni.cz> X-IsSubscribed: yes On 03/13/2015 05:42 AM, Jan Hubicka wrote: >> 2015-03-09 Martin Liska >> >> * config/i386/i386.c (def_builtin): Collect union of all >> possible masks. >> (ix86_add_new_builtins): Do not iterate over all builtins >> in cases that isa value has no intersection with possible masks >> and(or) last passed value is equal to the provided. >> --- >> 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 ab8f03a..5f180b6 100644 >> --- a/gcc/config/i386/i386.c >> +++ b/gcc/config/i386/i386.c >> @@ -30592,6 +30592,8 @@ struct builtin_isa { >> >> static struct builtin_isa ix86_builtins_isa[(int) IX86_BUILTIN_MAX]; >> >> +/* Union of all masks that are part of builtin_isa structures. */ >> +static HOST_WIDE_INT defined_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 >> @@ -30619,6 +30621,7 @@ def_builtin (HOST_WIDE_INT mask, const char *name, >> if (!(mask & OPTION_MASK_ISA_64BIT) || TARGET_64BIT) >> { >> ix86_builtins_isa[(int) code].isa = mask; >> + defined_isa_values |= mask; > > I think you can move this down to set_and_not_build_p set. Please add also > comment explaining the caching mehanism. Hi. Explanation of the patch is introduced. >> >> mask &= ~OPTION_MASK_ISA_64BIT; >> if (mask == 0 >> @@ -30670,6 +30673,14 @@ 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; >> + >> + if ((isa & defined_isa_values) == 0 || isa == last_tested_isa_value) > > Heer you need to compare (isa & defined_isa_values) == (isa & > last_tested_isa_value) right, because we have isa flags that enable no > builtins. I do not understand why, the guard simply ignores last value, which is already processed and 'isa' with any intersection with defined_isa_values. Maybe I miss something? Thanks, Martin > > Honza > From f40f0fa07d8a9643050c30cd4e29c8c4c8de6cce Mon Sep 17 00:00:00 2001 From: marxin Date: Sun, 8 Mar 2015 19:39:55 -0500 Subject: [PATCH] def_builtin_const: speed-up. gcc/ChangeLog: 2015-03-09 Martin Liska * config/i386/i386.c (def_builtin): Collect union of all possible masks. (ix86_add_new_builtins): Do not iterate over all builtins in cases that isa value has no intersection with possible masks and(or) last passed value is equal to the provided. --- gcc/config/i386/i386.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index ab8f03a..134b349 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -30592,6 +30592,8 @@ struct builtin_isa { static struct builtin_isa ix86_builtins_isa[(int) IX86_BUILTIN_MAX]; +/* Union of all masks that are part of builtin_isa structures. */ +static HOST_WIDE_INT defined_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 @@ -30619,6 +30621,7 @@ def_builtin (HOST_WIDE_INT mask, const char *name, if (!(mask & OPTION_MASK_ISA_64BIT) || TARGET_64BIT) { ix86_builtins_isa[(int) code].isa = mask; + defined_isa_values |= mask; mask &= ~OPTION_MASK_ISA_64BIT; if (mask == 0 @@ -30670,6 +30673,17 @@ 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. */ + if ((isa & defined_isa_values) == 0 || isa == last_tested_isa_value) + return; + + last_tested_isa_value = isa; + int i; tree saved_current_target_pragma = current_target_pragma; current_target_pragma = NULL_TREE; -- 2.1.2