From patchwork Fri Nov 7 00:59:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 407922 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 9C0F01400A0 for ; Fri, 7 Nov 2014 12:05:34 +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=mqWwWZZ2G+QoG0mgm3AnvCpNyx93tI+jdzOuyMIsFRhEmnutTqgK4 tJjiIhc1Ec4aeXbGadtrrbzwLyLHeEpwtKcowhIyd/Qg7qR73TodRYZPhodzPhaI bksVNj/3N2qhRpRy7LjF0LQzj4756DQcGmyKAcLz/oL2tolUVoK7PI= 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=OHkdwTjPw7g0Ev8ww9Nsjhhp92s=; b=GhghPAo2QPGw5WU8sIoQ Y+wiCB8HlLICVXxcECMVJKg8lgGFovQsh4qIhmeGBFOWdwmIjJmXqHqeBQBipb1V lXJVsQqvRZFajSMucKMXc/LELKjIIMKB5HrXu6UBTxPCjozatNUnYniRBWnxRnte rKqc5roznw19I0upJlgbnd8= Received: (qmail 6044 invoked by alias); 7 Nov 2014 01:04:06 -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 5978 invoked by uid 89); 7 Nov 2014 01:04:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 07 Nov 2014 01:04:02 +0000 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 sA7140Jv003611 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 6 Nov 2014 20:04:01 -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 sA713ouX008548; Thu, 6 Nov 2014 20:04:00 -0500 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [gimple-classes, committed 15/17] tree-ssa-phiprop.c: Use gassign Date: Thu, 6 Nov 2014 19:59:29 -0500 Message-Id: <1415321971-19808-16-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-IsSubscribed: yes gcc/ChangeLog.gimple-classes: * tree-ssa-phiprop.c (phiprop_insert_phi): Strengthen param "use_stmt" from gimple to gassign *. Add checked cast. (propagate_with_phi): Add checked casts. Replace is_gimple_assign with a dyn_cast, introducing local "use_assign" and using it in place of "use_stmt" for typesafety. --- gcc/ChangeLog.gimple-classes | 8 ++++++++ gcc/tree-ssa-phiprop.c | 33 ++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 6bb28db..0e8ed9a 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,13 @@ 2014-11-06 David Malcolm + * tree-ssa-phiprop.c (phiprop_insert_phi): Strengthen param + "use_stmt" from gimple to gassign *. Add checked cast. + (propagate_with_phi): Add checked casts. Replace is_gimple_assign + with a dyn_cast, introducing local "use_assign" and using it in + place of "use_stmt" for typesafety. + +2014-11-06 David Malcolm + * tree-ssa-phiopt.c (jump_function_from_stmt): Strengthen param "stmt" from gimple to gassign *. (rhs_is_fed_for_value_replacement): Replace is_gimple_assign with diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c index 8caab38..45d7f65 100644 --- a/gcc/tree-ssa-phiprop.c +++ b/gcc/tree-ssa-phiprop.c @@ -149,7 +149,7 @@ phivn_valid_p (struct phiprop_d *phivn, tree name, basic_block bb) BB with the virtual operands from USE_STMT. */ static tree -phiprop_insert_phi (basic_block bb, gphi *phi, gimple use_stmt, +phiprop_insert_phi (basic_block bb, gphi *phi, gassign *use_stmt, struct phiprop_d *phivn, size_t n) { tree res; @@ -157,8 +157,7 @@ phiprop_insert_phi (basic_block bb, gphi *phi, gimple use_stmt, edge_iterator ei; edge e; - gcc_assert (is_gimple_assign (use_stmt) - && gimple_assign_rhs_code (use_stmt) == MEM_REF); + gcc_assert (gimple_assign_rhs_code (use_stmt) == MEM_REF); /* Build a new PHI node to replace the definition of the indirect reference lhs. */ @@ -186,7 +185,7 @@ phiprop_insert_phi (basic_block bb, gphi *phi, gimple use_stmt, || phivn[SSA_NAME_VERSION (old_arg)].value == NULL_TREE)) { gimple def_stmt = SSA_NAME_DEF_STMT (old_arg); - old_arg = gimple_assign_rhs1 (def_stmt); + old_arg = gimple_assign_rhs1 (as_a (def_stmt)); locus = gimple_location (def_stmt); } @@ -289,7 +288,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, gimple def_stmt = SSA_NAME_DEF_STMT (arg); if (!gimple_assign_single_p (def_stmt)) return false; - arg = gimple_assign_rhs1 (def_stmt); + arg = gimple_assign_rhs1 (as_a (def_stmt)); } if (TREE_CODE (arg) != ADDR_EXPR && !(TREE_CODE (arg) == SSA_NAME @@ -309,7 +308,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, copy chains for ptr. */ while (single_imm_use (ptr, &use, &use_stmt) && gimple_assign_ssa_name_copy_p (use_stmt)) - ptr = gimple_assign_lhs (use_stmt); + ptr = gimple_assign_lhs (as_a (use_stmt)); /* Replace the first dereference of *ptr if there is one and if we can move the loads to the place of the ptr phi node. */ @@ -326,16 +325,19 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, continue; /* Check whether this is a load of *ptr. */ - if (!(is_gimple_assign (use_stmt) - && TREE_CODE (gimple_assign_lhs (use_stmt)) == SSA_NAME - && gimple_assign_rhs_code (use_stmt) == MEM_REF - && TREE_OPERAND (gimple_assign_rhs1 (use_stmt), 0) == ptr - && integer_zerop (TREE_OPERAND (gimple_assign_rhs1 (use_stmt), 1)) + gassign *use_assign = dyn_cast (use_stmt); + if (!use_assign) + continue; + + if (!(TREE_CODE (gimple_assign_lhs (use_assign)) == SSA_NAME + && gimple_assign_rhs_code (use_assign) == MEM_REF + && TREE_OPERAND (gimple_assign_rhs1 (use_assign), 0) == ptr + && integer_zerop (TREE_OPERAND (gimple_assign_rhs1 (use_assign), 1)) && (!type || types_compatible_p - (TREE_TYPE (gimple_assign_lhs (use_stmt)), type)) + (TREE_TYPE (gimple_assign_lhs (use_assign)), type)) /* We cannot replace a load that may throw or is volatile. */ - && !stmt_can_throw_internal (use_stmt))) + && !stmt_can_throw_internal (use_assign))) continue; /* Check if we can move the loads. The def stmt of the virtual use @@ -352,7 +354,8 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, is the first load transformation. */ if (!phi_inserted) { - res = phiprop_insert_phi (bb, phi, use_stmt, phivn, n); + res = phiprop_insert_phi (bb, phi, use_assign, + phivn, n); type = TREE_TYPE (res); /* Remember the value we created for *ptr. */ @@ -371,7 +374,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, { /* Further replacements are easy, just make a copy out of the load. */ - gimple_assign_set_rhs1 (use_stmt, res); + gimple_assign_set_rhs1 (use_assign, res); update_stmt (use_stmt); }