From patchwork Fri Dec 23 17:47:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 708493 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 3tlbTH0rtsz9syB for ; Sat, 24 Dec 2016 04:48:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="DCpvVr0Z"; 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:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=AI9Imbb+XgoERlKWxBGKR5goh0inltes7lhfu3yC33WMYOtInl9bP gT8tAGJg43icRZeQ1iw4ZF0U6WXFFFYIEt7t8bTmqpwAbCQELV9A1BvciWZ5FR8c bHWaQGaP8mLufLkPll/AdfGlNI4RPenjhpy6Gq/BVkugDWOZci29yg= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=7yj7wL9PuPWev0jlFJrS6Ll0Wws=; b=DCpvVr0ZBiVe0R3awLBf blDHWePisnORYGX0O2YVxQqUqxwL2RqwE3f/02TQg0BQKeJf+OyRSr7V9/VGj6QS sGvejPQG3AIcl7Upe59cvtsUqftIMVPBseI49MqbLLgvQrFsqsKrkH77y5eAR2aA a/990bqKyrWlBdnz6vYwz7I= Received: (qmail 107178 invoked by alias); 23 Dec 2016 17:47:52 -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 107151 invoked by uid 89); 23 Dec 2016 17:47:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=SSA_NAME_VAR, ssa_name_var, is_gimple_reg, misses X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Dec 2016 17:47:50 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D6D88707; Fri, 23 Dec 2016 09:47:48 -0800 (PST) Received: from localhost (e105548-lin.manchester.arm.com [10.45.32.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7E6583F24D for ; Fri, 23 Dec 2016 09:47:48 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Make it cheaper to test whether an SSA name is a virtual operand Date: Fri, 23 Dec 2016 17:47:37 +0000 Message-ID: <87h95ur0zq.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 virtual_operand_p handled SSA names by looking at the flags of the underlying variable. This seems to be a relatively common source of cache misses, mainly because virtual_operand_p is the first thing tested by is_gimple_reg. This patch caches the information in the SSA name itself. Several flags seem to be free so the patch arbitrarily uses public_flag. Tested on aarch64-linux-gnu and x86_64-linux-gnu. It improves compile time by a small (<1%) but reproducable amount on the tests I've tried. OK to install? Thanks, Richard gcc/ * tree-core.h (tree_base): Document the meaning of public_flag for SSA names. * tree.h (SSA_NAME_IS_VIRTUAL_OPERAND): New macro. (SET_SSA_NAME_VAR_OR_IDENTIFIER): Record whether the variable is a virtual operand. * gimple-expr.h (virtual_operand_p): Use SSA_NAME_IS_VIRTUAL_OPERAND. diff --git a/gcc/gimple-expr.h b/gcc/gimple-expr.h index f2ccd29..faf4c53 100644 --- a/gcc/gimple-expr.h +++ b/gcc/gimple-expr.h @@ -105,11 +105,7 @@ static inline bool virtual_operand_p (tree op) { if (TREE_CODE (op) == SSA_NAME) - { - op = SSA_NAME_VAR (op); - if (!op) - return false; - } + return SSA_NAME_IS_VIRTUAL_OPERAND (op); if (TREE_CODE (op) == VAR_DECL) return VAR_DECL_IS_VIRTUAL_OPERAND (op); diff --git a/gcc/tree-core.h b/gcc/tree-core.h index eec2d4f3..59d771c 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -1091,6 +1091,9 @@ struct GTY(()) tree_base { FALLTHROUGH_LABEL_P in LABEL_DECL + SSA_NAME_IS_VIRTUAL_OPERAND in + SSA_NAME + private_flag: TREE_PRIVATE in diff --git a/gcc/tree.h b/gcc/tree.h index 62cd7bb..e994e93 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1665,6 +1665,11 @@ extern void protected_set_expr_location (tree, location_t); /* SSA_NAME accessors. */ +/* Whether SSA_NAME NODE is a virtual operand. This simply caches the + information in the underlying SSA_NAME_VAR for efficiency. */ +#define SSA_NAME_IS_VIRTUAL_OPERAND(NODE) \ + SSA_NAME_CHECK (NODE)->base.public_flag + /* Returns the IDENTIFIER_NODE giving the SSA name a name or NULL_TREE if there is no name associated with it. */ #define SSA_NAME_IDENTIFIER(NODE) \ @@ -1683,7 +1688,16 @@ extern void protected_set_expr_location (tree, location_t); ? NULL_TREE : (NODE)->ssa_name.var) #define SET_SSA_NAME_VAR_OR_IDENTIFIER(NODE,VAR) \ - do { SSA_NAME_CHECK (NODE)->ssa_name.var = (VAR); } while (0) + do \ + { \ + tree var_ = (VAR); \ + SSA_NAME_CHECK (NODE)->ssa_name.var = var_; \ + SSA_NAME_IS_VIRTUAL_OPERAND (NODE) \ + = (var_ \ + && TREE_CODE (var_) == VAR_DECL \ + && VAR_DECL_IS_VIRTUAL_OPERAND (var_)); \ + } \ + while (0) /* Returns the statement which defines this SSA name. */ #define SSA_NAME_DEF_STMT(NODE) SSA_NAME_CHECK (NODE)->ssa_name.def_stmt