From patchwork Tue Jun 22 18:36:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 56563 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]) by ozlabs.org (Postfix) with SMTP id D5BB8B6F16 for ; Wed, 23 Jun 2010 04:36:46 +1000 (EST) Received: (qmail 12394 invoked by alias); 22 Jun 2010 18:36:45 -0000 Received: (qmail 12383 invoked by uid 22791); 22 Jun 2010 18:36:43 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam-dmz.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Jun 2010 18:36:39 +0000 Received: from localhost (kamzik.ms.mff.cuni.cz [195.113.18.74]) by nikam.ms.mff.cuni.cz (Postfix) with ESMTP id 194119AC883 for ; Tue, 22 Jun 2010 20:36:37 +0200 (CEST) Received: by localhost (Postfix, from userid 16202) id 10D4737F8F; Tue, 22 Jun 2010 20:36:37 +0200 (CEST) Date: Tue, 22 Jun 2010 20:36:37 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Make dominated_by_p and get_immediate_dominator inline Message-ID: <20100622183636.GC23996@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) 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 Hi, this is change I forgot in my tree for a while. get_immediate_dominator and dominated_by_p are one of most frequently called functions and they are good candidates for inlining. Dominated_by_p has fallback path calling et_forest code. Most of passes don't use dynamic dominance info and thus we never get there. I was thinking about making specific version for non-dynamic dominators, but since the most common calls from dominated_by_p comes from cfg.c (dominance frontiers computation) that is sort of generic, it would require more bookkeping of when info is dynamic and when not. Hopefully the cold path is not going to cause too much of trouble. The patch needs to include et-forest.h in basic-block.h, but I do not see much way around. Bootstrapped/regtested x86_64-linux OK? Honza * dominance.c (dom_convert_dir_to_idx, get_immediate_dominator, dominated_by_p): Move from here to... * basic-block.h: Include et-forest.h * dominance.c (dom_convert_dir_to_idx, get_immediate_dominator, dominated_by_p): ... here; use checking_assert. Index: dominance.c =================================================================== --- dominance.c (revision 161199) +++ dominance.c (working copy) @@ -183,18 +183,6 @@ init_dom_info (struct dom_info *di, enum #undef init_ar -/* Map dominance calculation type to array index used for various - dominance information arrays. This version is simple -- it will need - to be modified, obviously, if additional values are added to - cdi_direction. */ - -static unsigned int -dom_convert_dir_to_idx (enum cdi_direction dir) -{ - gcc_assert (dir == CDI_DOMINATORS || dir == CDI_POST_DOMINATORS); - return dir - 1; -} - /* Free all allocated memory in DI, but not DI itself. */ static void @@ -695,21 +683,6 @@ free_dominance_info (enum cdi_direction dom_computed[dir_index] = DOM_NONE; } -/* Return the immediate dominator of basic block BB. */ -basic_block -get_immediate_dominator (enum cdi_direction dir, basic_block bb) -{ - unsigned int dir_index = dom_convert_dir_to_idx (dir); - struct et_node *node = bb->dom[dir_index]; - - gcc_assert (dom_computed[dir_index]); - - if (!node->father) - return NULL; - - return (basic_block) node->father->data; -} - /* Set the immediate dominator of the block possibly removing existing edge. NULL can be used to remove any edge. */ void @@ -948,22 +921,6 @@ nearest_common_dominator_for_set (enum c && DFS_Number_Out (A) <= DFS_Number_Out(B); } */ -/* Return TRUE in case BB1 is dominated by BB2. */ -bool -dominated_by_p (enum cdi_direction dir, const_basic_block bb1, const_basic_block bb2) -{ - unsigned int dir_index = dom_convert_dir_to_idx (dir); - struct et_node *n1 = bb1->dom[dir_index], *n2 = bb2->dom[dir_index]; - - gcc_assert (dom_computed[dir_index]); - - if (dom_computed[dir_index] == DOM_OK) - return (n1->dfs_num_in >= n2->dfs_num_in - && n1->dfs_num_out <= n2->dfs_num_out); - - return et_below (n1, n2); -} - /* Returns the entry dfs number for basic block BB, in the direction DIR. */ unsigned Index: basic-block.h =================================================================== --- basic-block.h (revision 161199) +++ basic-block.h (working copy) @@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. #include "predict.h" #include "vec.h" #include "function.h" +#include "et-forest.h" /* Type we use to hold basic block counters. Should be at least 64bit. Although a counter cannot be negative, we use a signed @@ -837,6 +838,50 @@ enum cdi_direction CDI_POST_DOMINATORS = 2 }; +/* Map dominance calculation type to array index used for various + dominance information arrays. This version is simple -- it will need + to be modified, obviously, if additional values are added to + cdi_direction. */ + +static inline unsigned int +dom_convert_dir_to_idx (enum cdi_direction dir) +{ + gcc_checking_assert (dir == CDI_DOMINATORS || dir == CDI_POST_DOMINATORS); + return dir - 1; +} + +/* Return TRUE in case BB1 is dominated by BB2. */ +static inline bool +dominated_by_p (enum cdi_direction dir, const_basic_block bb1, const_basic_block bb2) +{ + unsigned int dir_index = dom_convert_dir_to_idx (dir); + struct et_node *n1 = bb1->dom[dir_index], *n2 = bb2->dom[dir_index]; + + gcc_checking_assert (dom_computed[dir_index]); + + if (dom_computed[dir_index] == DOM_OK) + return (n1->dfs_num_in >= n2->dfs_num_in + && n1->dfs_num_out <= n2->dfs_num_out); + + return et_below (n1, n2); +} + + +/* Return the immediate dominator of basic block BB. */ +static inline basic_block +get_immediate_dominator (enum cdi_direction dir, basic_block bb) +{ + unsigned int dir_index = dom_convert_dir_to_idx (dir); + struct et_node *node = bb->dom[dir_index]; + + gcc_checking_assert (dom_computed[dir_index]); + + if (!node->father) + return NULL; + + return (basic_block) node->father->data; +} + extern enum dom_state dom_info_state (enum cdi_direction); extern void set_dom_info_availability (enum cdi_direction, enum dom_state); extern bool dom_info_available_p (enum cdi_direction);