From patchwork Thu Oct 21 03:24:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 68516 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 44D18B70D1 for ; Thu, 21 Oct 2010 14:25:15 +1100 (EST) Received: (qmail 30522 invoked by alias); 21 Oct 2010 03:25:11 -0000 Received: (qmail 30497 invoked by uid 22791); 21 Oct 2010 03:25:09 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Oct 2010 03:25:03 +0000 Received: (qmail 2166 invoked from network); 21 Oct 2010 03:25:01 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 21 Oct 2010 03:25:01 -0000 Date: Wed, 20 Oct 2010 23:24:59 -0400 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Subject: [PATCH] use bb_has_abnormal_pred in a few places Message-ID: <20101021032457.GD2806@nightcrawler> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes 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 The patch below chanages several places to use bb_has_abnormal_pred instead of explicit loops. Tested on x86_64-unknown-linux-gnu. OK to commit? -Nathan * cfgloop.c (flow_loops_find): Call bb_has_abnormal_pred. * reload1.c (has_nonexceptional_receiver): Likewise. * tree-into-ssa.c (rewrite_update_enter_block): Likewise. (create_new_def_for): Likewise. * tree-cfgcleanup.c (remove_forwarder_block): Likewise. (merge_phi_nodes): Likewise. (has_abnormal_incoming_edge_p): Delete. diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index c242756..22bce4f 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -410,10 +410,7 @@ flow_loops_find (struct loops *loops) /* If we have an abnormal predecessor, do not consider the loop (not worth the problems). */ - FOR_EACH_EDGE (e, ei, header->preds) - if (e->flags & EDGE_ABNORMAL) - break; - if (e) + if (bb_has_abnormal_pred (header)) continue; FOR_EACH_EDGE (e, ei, header->preds) diff --git a/gcc/reload1.c b/gcc/reload1.c index e77a14b..c8fd33a 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -675,10 +675,8 @@ has_nonexceptional_receiver (void) /* Now see if there's a reachable block with an exceptional incoming edge. */ FOR_EACH_BB (bb) - if (bb->flags & BB_REACHABLE) - FOR_EACH_EDGE (e, ei, bb->preds) - if (e->flags & EDGE_ABNORMAL) - return true; + if (bb->flags & BB_REACHABLE && bb_has_abnormal_pred (bb)) + return true; /* No exceptional block reached exit unexceptionally. */ return false; diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index 3c1ca2d..ae23cfc 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -338,21 +338,6 @@ tree_forwarder_block_p (basic_block bb, bool phi_wanted) return true; } -/* Return true if BB has at least one abnormal incoming edge. */ - -static inline bool -has_abnormal_incoming_edge_p (basic_block bb) -{ - edge e; - edge_iterator ei; - - FOR_EACH_EDGE (e, ei, bb->preds) - if (e->flags & EDGE_ABNORMAL) - return true; - - return false; -} - /* If all the PHI nodes in DEST have alternatives for E1 and E2 and those alternatives are equal in each of the PHI nodes, then return true, else return false. */ @@ -418,8 +403,8 @@ remove_forwarder_block (basic_block bb) So if there is an abnormal edge to BB, proceed only if there is no abnormal edge to DEST and there are no phi nodes in DEST. */ - if (has_abnormal_incoming_edge_p (bb) - && (has_abnormal_incoming_edge_p (dest) + if (bb_has_abnormal_pred (bb) + && (bb_has_abnormal_pred (dest) || !gimple_seq_empty_p (phi_nodes (dest)))) return false; @@ -990,7 +975,7 @@ merge_phi_nodes (void) if (gimple_seq_empty_p (phi_nodes (dest)) /* We don't want to deal with a basic block with abnormal edges. */ - || has_abnormal_incoming_edge_p (bb)) + || bb_has_abnormal_pred (bb)) continue; if (!dominated_by_p (CDI_DOMINATORS, dest, bb)) diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index cbd629c..f52aea7 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -2063,8 +2063,6 @@ static void rewrite_update_enter_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, basic_block bb) { - edge e; - edge_iterator ei; bool is_abnormal_phi; gimple_stmt_iterator gsi; @@ -2080,13 +2078,7 @@ rewrite_update_enter_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, /* Mark the LHS if any of the arguments flows through an abnormal edge. */ - is_abnormal_phi = false; - FOR_EACH_EDGE (e, ei, bb->preds) - if (e->flags & EDGE_ABNORMAL) - { - is_abnormal_phi = true; - break; - } + is_abnormal_phi = bb_has_abnormal_pred (bb); /* If any of the PHI nodes is a replacement for a name in OLD_SSA_NAMES or it's one of the names in NEW_SSA_NAMES, then @@ -2838,17 +2830,10 @@ create_new_def_for (tree old_name, gimple stmt, def_operand_p def) if (gimple_code (stmt) == GIMPLE_PHI) { - edge e; - edge_iterator ei; basic_block bb = gimple_bb (stmt); /* If needed, mark NEW_NAME as occurring in an abnormal PHI node. */ - FOR_EACH_EDGE (e, ei, bb->preds) - if (e->flags & EDGE_ABNORMAL) - { - SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_name) = 1; - break; - } + SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_name) = bb_has_abnormal_pred (bb); } register_new_name_mapping (new_name, old_name);