From patchwork Fri Nov 7 00:59:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 407934 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 CBE731400D2 for ; Fri, 7 Nov 2014 12:22:56 +1100 (AEDT) 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:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=k1zSFTrtRzI4jevWsNVrZoCRVPUHiNSlk+6pm9P655QsmNev1zz+I FqxqNyZf7rZXpoO9t9qe/GFrjFnw7HtFaatlKRdcZmvfyI4HtKajVnddm4RkPfRz EYQjW0R8ZfioeQ/94+HQETr7VOKKkM0+muu0ED6RoBLlqMaT7VMjqs= 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:cc:subject:date:message-id:in-reply-to:references; s= default; bh=VbkHQNSAhl+wBcWGuD+BAwfT/RU=; b=osSRDi9iWuuYoh5Zf033 ZVLzkGHeiALBcfXTZn1Jl4GQGZuEuxdoaq58iJF5meBZi6XqhRnE39LFgcvpfdhB oxfttjpQ6dk3blcTPkX5LuRXQZ8Wzwi+5kFAblvT4zypQplTW/0ve1/OZZvcliHP mBE1kpKq3zQGgAPGf4YqyS8= Received: (qmail 31999 invoked by alias); 7 Nov 2014 01:22: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 31913 invoked by uid 89); 7 Nov 2014 01:22:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, T_FILL_THIS_FORM_SHORT autolearn=ham version=3.3.2 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 07 Nov 2014 01:22:33 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XmXxz-0004xv-FN for gcc-patches@gcc.gnu.org; Thu, 06 Nov 2014 20:04:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XmXxz-0004xS-7b for gcc-patches@gcc.gnu.org; Thu, 06 Nov 2014 20:03:55 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sA713sU1029306 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 6 Nov 2014 20:03:54 -0500 Received: from surprise.redhat.com (vpn-235-14.phx2.redhat.com [10.3.235.14]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sA713ouO008548; Thu, 6 Nov 2014 20:03:54 -0500 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [gimple-classes, committed 06/17] tree-predcom.c: Use gassign Date: Thu, 6 Nov 2014 19:59:20 -0500 Message-Id: <1415321971-19808-7-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1415321971-19808-1-git-send-email-dmalcolm@redhat.com> References: <1415321971-19808-1-git-send-email-dmalcolm@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 X-IsSubscribed: yes gcc/ChangeLog.gimple-classes: * tree-predcom.c (name_for_ref): Replace is_gimple_assign with a dyn_cast, introducing local gassign * "ref_assign", using it place of ref->stmt for typesafety. (find_looparound_phi): Likewise. Strengthen local "init_stmt" from gimple to gassign *, replacing a check against GIMPLE_ASSIGN with a dyn_cast. (replace_ref_with): Introduce local "assign_stmt" via a checked cast in the region, where we know "stmt" is a GIMPLE_ASSIGN, replacing the latter with the former for typesafety. (initialize_root_vars): Add a checked cast. (remove_stmt): Add checked casts. (find_use_stmt): Strengthen return type from gimple to gassign *. Replace check for GIMPLE_ASSIGN with a dyn_cast, introducing local "assign_stmt" and using it in place of "stmt" for typesafety. (find_associative_operation_root): Strengthen return type, param "stmt" and local "next" from gimple to gassign *. (find_common_use_stmt): Likewise for return type and locals "stmt1" and "stmt2". (combinable_refs_p): Likewise for local "stmt". (remove_name_from_operation): Likewise for param "stmt". (reassociate_to_the_same_stmt): Likewise for locals "stmt1", "stmt2", "root1", "root2", "s1", "s2". Introduce local gimple "stmt" and use in place of "s1" when updating gsi_stmt (bsi). --- gcc/ChangeLog.gimple-classes | 27 +++++++++++++++ gcc/tree-predcom.c | 79 ++++++++++++++++++++++---------------------- 2 files changed, 66 insertions(+), 40 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 55acc34..45fe6ed 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,32 @@ 2014-11-06 David Malcolm + * tree-predcom.c (name_for_ref): Replace is_gimple_assign with a + dyn_cast, introducing local gassign * "ref_assign", using it place + of ref->stmt for typesafety. + (find_looparound_phi): Likewise. Strengthen local "init_stmt" + from gimple to gassign *, replacing a check against GIMPLE_ASSIGN + with a dyn_cast. + (replace_ref_with): Introduce local "assign_stmt" via a checked + cast in the region, where we know "stmt" is a GIMPLE_ASSIGN, + replacing the latter with the former for typesafety. + (initialize_root_vars): Add a checked cast. + (remove_stmt): Add checked casts. + (find_use_stmt): Strengthen return type from gimple to gassign *. + Replace check for GIMPLE_ASSIGN with a dyn_cast, introducing + local "assign_stmt" and using it in place of "stmt" for + typesafety. + (find_associative_operation_root): Strengthen return type, param + "stmt" and local "next" from gimple to gassign *. + (find_common_use_stmt): Likewise for return type and locals + "stmt1" and "stmt2". + (combinable_refs_p): Likewise for local "stmt". + (remove_name_from_operation): Likewise for param "stmt". + (reassociate_to_the_same_stmt): Likewise for locals "stmt1", + "stmt2", "root1", "root2", "s1", "s2". Introduce local gimple + "stmt" and use in place of "s1" when updating gsi_stmt (bsi). + +2014-11-06 David Malcolm + * tree-loop-distribution.c (generate_memset_builtin): Strengthen locals "stmt" and "fn_call" from gimple to gassign * and gcall * respectively. diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c index 93a523c..fecb336 100644 --- a/gcc/tree-predcom.c +++ b/gcc/tree-predcom.c @@ -1062,12 +1062,12 @@ name_for_ref (dref ref) { tree name; - if (is_gimple_assign (ref->stmt)) + if (gassign *ref_assign = dyn_cast (ref->stmt)) { if (!ref->ref || DR_IS_READ (ref->ref)) - name = gimple_assign_lhs (ref->stmt); + name = gimple_assign_lhs (ref_assign); else - name = gimple_assign_rhs1 (ref->stmt); + name = gimple_assign_rhs1 (ref_assign); } else name = PHI_RESULT (ref->stmt); @@ -1127,17 +1127,17 @@ find_looparound_phi (struct loop *loop, dref ref, dref root) { tree name, init, init_ref; gphi *phi = NULL; - gimple init_stmt; + gassign *init_stmt; edge latch = loop_latch_edge (loop); struct data_reference init_dr; gphi_iterator psi; - if (is_gimple_assign (ref->stmt)) + if (gassign *ref_assign = dyn_cast (ref->stmt)) { if (DR_IS_READ (ref->ref)) - name = gimple_assign_lhs (ref->stmt); + name = gimple_assign_lhs (ref_assign); else - name = gimple_assign_rhs1 (ref->stmt); + name = gimple_assign_rhs1 (ref_assign); } else name = PHI_RESULT (ref->stmt); @@ -1157,8 +1157,8 @@ find_looparound_phi (struct loop *loop, dref ref, dref root) init = PHI_ARG_DEF_FROM_EDGE (phi, loop_preheader_edge (loop)); if (TREE_CODE (init) != SSA_NAME) return NULL; - init_stmt = SSA_NAME_DEF_STMT (init); - if (gimple_code (init_stmt) != GIMPLE_ASSIGN) + init_stmt = dyn_cast (SSA_NAME_DEF_STMT (init)); + if (!init_stmt) return NULL; gcc_assert (gimple_assign_lhs (init_stmt) == init); @@ -1323,7 +1323,7 @@ replace_ref_with (gimple stmt, tree new_tree, bool set, bool in_lhs) /* Since the reference is of gimple_reg type, it should only appear as lhs or rhs of modify statement. */ - gcc_assert (is_gimple_assign (stmt)); + gassign *assign_stmt = as_a (stmt); bsi = gsi_for_stmt (stmt); @@ -1358,15 +1358,15 @@ replace_ref_with (gimple stmt, tree new_tree, bool set, bool in_lhs) */ - val = gimple_assign_lhs (stmt); + val = gimple_assign_lhs (assign_stmt); if (TREE_CODE (val) != SSA_NAME) { - val = gimple_assign_rhs1 (stmt); - gcc_assert (gimple_assign_single_p (stmt)); + val = gimple_assign_rhs1 (assign_stmt); + gcc_assert (gimple_assign_single_p (assign_stmt)); if (TREE_CLOBBER_P (val)) val = get_or_create_ssa_default_def (cfun, SSA_NAME_VAR (new_tree)); else - gcc_assert (gimple_assign_copy_p (stmt)); + gcc_assert (gimple_assign_copy_p (assign_stmt)); } } else @@ -1378,7 +1378,7 @@ replace_ref_with (gimple stmt, tree new_tree, bool set, bool in_lhs) VAL = OLD NEW = VAL */ - val = gimple_assign_lhs (stmt); + val = gimple_assign_lhs (assign_stmt); } new_stmt = gimple_build_assign (new_tree, unshare_expr (val)); @@ -1478,7 +1478,7 @@ initialize_root_vars (struct loop *loop, chain_p chain, bitmap tmp_vars) chain->vars.create (n + 1); if (chain->type == CT_COMBINATION) - ref = gimple_assign_lhs (root->stmt); + ref = gimple_assign_lhs (as_a (root->stmt)); else ref = DR_REF (root->ref); @@ -1681,7 +1681,7 @@ remove_stmt (gimple stmt) if (!next || !gimple_assign_ssa_name_copy_p (next) - || gimple_assign_rhs1 (next) != name) + || gimple_assign_rhs1 (as_a (next)) != name) return; stmt = next; @@ -1693,7 +1693,7 @@ remove_stmt (gimple stmt) bsi = gsi_for_stmt (stmt); - name = gimple_assign_lhs (stmt); + name = gimple_assign_lhs (as_a (stmt)); gcc_assert (TREE_CODE (name) == SSA_NAME); next = single_nonlooparound_use (name); @@ -1705,7 +1705,7 @@ remove_stmt (gimple stmt) if (!next || !gimple_assign_ssa_name_copy_p (next) - || gimple_assign_rhs1 (next) != name) + || gimple_assign_rhs1 (as_a (next)) != name) return; stmt = next; @@ -1946,37 +1946,37 @@ chain_can_be_combined_p (chain_p chain) statements, NAME is replaced with the actual name used in the returned statement. */ -static gimple +static gassign * find_use_stmt (tree *name) { - gimple stmt; tree rhs, lhs; /* Skip over assignments. */ while (1) { - stmt = single_nonlooparound_use (*name); + gimple stmt = single_nonlooparound_use (*name); if (!stmt) return NULL; - if (gimple_code (stmt) != GIMPLE_ASSIGN) + gassign *assign_stmt = dyn_cast (stmt); + if (!assign_stmt) return NULL; - lhs = gimple_assign_lhs (stmt); + lhs = gimple_assign_lhs (assign_stmt); if (TREE_CODE (lhs) != SSA_NAME) return NULL; - if (gimple_assign_copy_p (stmt)) + if (gimple_assign_copy_p (assign_stmt)) { - rhs = gimple_assign_rhs1 (stmt); + rhs = gimple_assign_rhs1 (assign_stmt); if (rhs != *name) return NULL; *name = lhs; } - else if (get_gimple_rhs_class (gimple_assign_rhs_code (stmt)) + else if (get_gimple_rhs_class (gimple_assign_rhs_code (assign_stmt)) == GIMPLE_BINARY_RHS) - return stmt; + return assign_stmt; else return NULL; } @@ -1999,11 +1999,11 @@ may_reassociate_p (tree type, enum tree_code code) tree of the same operations and returns its root. Distance to the root is stored in DISTANCE. */ -static gimple -find_associative_operation_root (gimple stmt, unsigned *distance) +static gassign * +find_associative_operation_root (gassign *stmt, unsigned *distance) { tree lhs; - gimple next; + gassign *next; enum tree_code code = gimple_assign_rhs_code (stmt); tree type = TREE_TYPE (gimple_assign_lhs (stmt)); unsigned dist = 0; @@ -2036,10 +2036,10 @@ find_associative_operation_root (gimple stmt, unsigned *distance) tree formed by this operation instead of the statement that uses NAME1 or NAME2. */ -static gimple +static gassign * find_common_use_stmt (tree *name1, tree *name2) { - gimple stmt1, stmt2; + gassign *stmt1, *stmt2; stmt1 = find_use_stmt (name1); if (!stmt1) @@ -2074,7 +2074,7 @@ combinable_refs_p (dref r1, dref r2, bool aswap; tree atype; tree name1, name2; - gimple stmt; + gassign *stmt; name1 = name_for_ref (r1); name2 = name_for_ref (r2); @@ -2111,13 +2111,11 @@ combinable_refs_p (dref r1, dref r2, an assignment of the remaining operand. */ static void -remove_name_from_operation (gimple stmt, tree op) +remove_name_from_operation (gassign *stmt, tree op) { tree other_op; gimple_stmt_iterator si; - gcc_assert (is_gimple_assign (stmt)); - if (gimple_assign_rhs1 (stmt) == op) other_op = gimple_assign_rhs2 (stmt); else @@ -2138,7 +2136,7 @@ remove_name_from_operation (gimple stmt, tree op) static gimple reassociate_to_the_same_stmt (tree name1, tree name2) { - gimple stmt1, stmt2, root1, root2, s1, s2; + gassign *stmt1, *stmt2, *root1, *root2, *s1, *s2; gassign *new_stmt, *tmp_stmt; tree new_name, tmp_name, var, r1, r2; unsigned dist1, dist2; @@ -2207,8 +2205,9 @@ reassociate_to_the_same_stmt (tree name1, tree name2) bsi = gsi_for_stmt (s1); gimple_assign_set_rhs_with_ops (&bsi, code, new_name, tmp_name); - s1 = gsi_stmt (bsi); - update_stmt (s1); + + gimple stmt = gsi_stmt (bsi); + update_stmt (stmt); gsi_insert_before (&bsi, new_stmt, GSI_SAME_STMT); gsi_insert_before (&bsi, tmp_stmt, GSI_SAME_STMT);