From patchwork Thu Nov 6 14:32:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 407563 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 B498C1400B6 for ; Fri, 7 Nov 2014 01:53:30 +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=G3aGpEoKpGLwlfpWtzIL++wfw8jBdkHGxfqvkWWjvKkwXLgD8Lggf RIB2Xk/MLRhLnA9LQphCTOMMI5dxDs0iAB2s6Dx34mIx3LJ6YCd88pZjU+om5cRP zlGDOTAuwN4RqEGHcAuXtljb1/dBaP2g19tF0k9ito7DQCznyGHWHw= 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=rRipYiLMJ7DUvTws18L/c6hFgx0=; b=caacku7wDunMdy/3JSnT +zVGR8XJGTQi7aEqtkoeeF9OhD+JsLP+WKcHmjxiKH4wueS5Z7CnlSZzCohzZAPI e1fvjCJjwNkZ9xM3jCSolaQZPut7We+dzRjXVi49tTV4W5EpNiM5J7/VEpVQPS+7 ZoxT3o/XO8egGL0jJ9xaCiM= Received: (qmail 12561 invoked by alias); 6 Nov 2014 14:52:55 -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 12492 invoked by uid 89); 6 Nov 2014 14:52:54 -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 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; Thu, 06 Nov 2014 14:52:52 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XmOBK-0006q1-En for gcc-patches@gcc.gnu.org; Thu, 06 Nov 2014 09:37:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59560) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XmOBK-0006pp-7H for gcc-patches@gcc.gnu.org; Thu, 06 Nov 2014 09:37:02 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sA6Eb0P9005291 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 6 Nov 2014 09:37:01 -0500 Received: from surprise.redhat.com (vpn-235-14.phx2.redhat.com [10.3.235.14]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sA6Eag85016497; Thu, 6 Nov 2014 09:36:59 -0500 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [gimple-classes, committed 27/44] tree-ssa-dce.c: Use gassign Date: Thu, 6 Nov 2014 09:32:03 -0500 Message-Id: <1415284340-14186-28-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1415284340-14186-1-git-send-email-dmalcolm@redhat.com> References: <1415284340-14186-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-ssa-dce.c (mark_stmt_if_obviously_necessary): Within case GIMPLE_ASSIGN, introduce local "assign_stmt" and use in place of "stmt" for typesafety. (mark_all_reaching_defs_necessary_1): Add a checked cast. (propagate_necessity): Likewise. (remove_dead_stmt): Introduce local gassign * "assign_stmt" from result of gimple_assign_single_p and use it in place of "stmt" for typesafety. --- gcc/ChangeLog.gimple-classes | 11 +++++++++++ gcc/tree-ssa-dce.c | 22 +++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 19a8295..8230179 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,16 @@ 2014-11-03 David Malcolm + * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Within + case GIMPLE_ASSIGN, introduce local "assign_stmt" and use in place + of "stmt" for typesafety. + (mark_all_reaching_defs_necessary_1): Add a checked cast. + (propagate_necessity): Likewise. + (remove_dead_stmt): Introduce local gassign * "assign_stmt" from + result of gimple_assign_single_p and use it in place of "stmt" for + typesafety. + +2014-11-03 David Malcolm + * tree-ssa-copy.c (stmt_may_generate_copy): Replace check against GIMPLE_ASSIGN with a dyn_cast, introducing local gassign * "assign_stmt", using it in place of "stmt" for typesafety. diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 20a4e40..bf2cae6 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -289,9 +289,12 @@ mark_stmt_if_obviously_necessary (gimple stmt, bool aggressive) break; case GIMPLE_ASSIGN: - if (TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME - && TREE_CLOBBER_P (gimple_assign_rhs1 (stmt))) - return; + { + gassign *assign_stmt = as_a (stmt); + if (TREE_CODE (gimple_assign_lhs (assign_stmt)) == SSA_NAME + && TREE_CLOBBER_P (gimple_assign_rhs1 (assign_stmt))) + return; + } break; default: @@ -570,7 +573,7 @@ mark_all_reaching_defs_necessary_1 (ao_ref *ref ATTRIBUTE_UNUSED, if (!chain_ovfl && gimple_assign_single_p (def_stmt)) { - tree lhs = gimple_assign_lhs (def_stmt); + tree lhs = gimple_assign_lhs (as_a (def_stmt)); if (!ref_may_be_aliased (lhs)) return false; } @@ -868,7 +871,7 @@ propagate_necessity (bool aggressive) { tree rhs; /* If this is a load mark things necessary. */ - rhs = gimple_assign_rhs1 (stmt); + rhs = gimple_assign_rhs1 (as_a (stmt)); if (TREE_CODE (rhs) != SSA_NAME && !is_gimple_min_invariant (rhs) && TREE_CODE (rhs) != CONSTRUCTOR) @@ -1125,18 +1128,19 @@ remove_dead_stmt (gimple_stmt_iterator *i, basic_block bb) /* If this is a store into a variable that is being optimized away, add a debug bind stmt if possible. */ + gassign *assign_stmt; if (MAY_HAVE_DEBUG_STMTS - && gimple_assign_single_p (stmt) - && is_gimple_val (gimple_assign_rhs1 (stmt))) + && (assign_stmt = gimple_assign_single_p (stmt)) + && is_gimple_val (gimple_assign_rhs1 (assign_stmt))) { - tree lhs = gimple_assign_lhs (stmt); + tree lhs = gimple_assign_lhs (assign_stmt); if ((TREE_CODE (lhs) == VAR_DECL || TREE_CODE (lhs) == PARM_DECL) && !DECL_IGNORED_P (lhs) && is_gimple_reg_type (TREE_TYPE (lhs)) && !is_global_var (lhs) && !DECL_HAS_VALUE_EXPR_P (lhs)) { - tree rhs = gimple_assign_rhs1 (stmt); + tree rhs = gimple_assign_rhs1 (assign_stmt); gdebug *note = gimple_build_debug_bind (lhs, unshare_expr (rhs), stmt); gsi_insert_after (i, note, GSI_SAME_STMT);