From patchwork Mon Oct 27 20:41:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 403906 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 B6D3E140077 for ; Tue, 28 Oct 2014 07:46:06 +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=Xes9jUv1gHbqeJp+e+SSmZrwmapjeZWkXTAkaRfAzkc4UstYGhhgd YPblXyT382eLYQp+9uvYJagyQMYUE4ZcJHd2s3RZD6A+yJjItgPaBPtcJeX4CmGE L4/QMuohbwoBLrSmFss0pqYydswn/mE7WGcIZQ+ufrfnH5g/rMwZEI= 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=6vXMzuejPmHgAe4Tl9wjfwpkiLo=; b=YyKMDkFA301zoYpr39zn Adzl1Yki7C8IlSIDKK7EwtOSBA6o05kifrv/k0ooT1PrLNWMb2muHGRkUnCAlVQW NUbQ1uWkIdsnhs5Ifrkzpc0Y+0RkVbPPwx0oZEOEKEn32eczLDUC0xjq+bsk66Gp oMDPPzFoXtfK5SEP91/LJmw= Received: (qmail 19316 invoked by alias); 27 Oct 2014 20:38:14 -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 8325 invoked by uid 89); 27 Oct 2014 20:36:14 -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; Mon, 27 Oct 2014 20:36:11 +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 s9RKZcHc000356 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 27 Oct 2014 16:35:39 -0400 Received: from c64.redhat.com (vpn-236-51.phx2.redhat.com [10.3.236.51]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9RKYt5u021050; Mon, 27 Oct 2014 16:35:37 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [gimple-classes, committed 72/92] Concretize gimple_cond_set_code Date: Mon, 27 Oct 2014 16:41:10 -0400 Message-Id: <1414442490-14841-73-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1414442490-14841-1-git-send-email-dmalcolm@redhat.com> References: <1414442490-14841-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes This corresponds to: [PATCH 74/89] Concretize gimple_cond_set_code https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01209.html from the original 89-patch kit That earlier patch was approved by Jeff: > Fine once prerequisites go in. in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00849.html gcc/ * gimple.h (gimple_cond_set_code): Require a gimple_cond. * tree-complex.c (expand_complex_comparison): Add a checked cast to gimple_cond within "case GIMPLE_COND". * tree-ssa-loop-ivcanon.c (create_canonical_iv): Convert local "cond" to a gimple_cond, adding a checked cast. The existing code requires that the last statement before the exit edge have code GIMPLE_COND, though it's not clear to me where this is verified. * tree-ssa-loop-ivopts.c (rewrite_use_compare): Add a checked cast to gimple_cond on "use->stmt". * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Convert local "exit_if" to gimple_cond, adding a checked cast. It's not clear to me exactly where the GIMPLE_COND-ness of this is established, but the existing code requires it. (canonicalize_loop_ivs): Similarly for "stmt". * tree-ssa-propagate.c (propagate_tree_value_into_stmt): Replace a check against GIMPLE_COND with a dyn_cast. --- gcc/ChangeLog.gimple-classes | 26 ++++++++++++++++++++++++++ gcc/gimple.h | 3 +-- gcc/tree-complex.c | 9 ++++++--- gcc/tree-ssa-loop-ivcanon.c | 4 ++-- gcc/tree-ssa-loop-ivopts.c | 7 ++++--- gcc/tree-ssa-loop-manip.c | 8 ++++---- gcc/tree-ssa-propagate.c | 8 ++++---- 7 files changed, 47 insertions(+), 18 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 2bff31c..503fd44 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,31 @@ 2014-10-24 David Malcolm + Concretize gimple_cond_set_code + + * gimple.h (gimple_cond_set_code): Require a gimple_cond. + + * tree-complex.c (expand_complex_comparison): Add a checked cast to + gimple_cond within "case GIMPLE_COND". + + * tree-ssa-loop-ivcanon.c (create_canonical_iv): Convert local "cond" + to a gimple_cond, adding a checked cast. The existing code requires + that the last statement before the exit edge have code GIMPLE_COND, + though it's not clear to me where this is verified. + + * tree-ssa-loop-ivopts.c (rewrite_use_compare): Add a checked cast + to gimple_cond on "use->stmt". + + * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Convert + local "exit_if" to gimple_cond, adding a checked cast. It's not + clear to me exactly where the GIMPLE_COND-ness of this is + established, but the existing code requires it. + (canonicalize_loop_ivs): Similarly for "stmt". + + * tree-ssa-propagate.c (propagate_tree_value_into_stmt): Replace + a check against GIMPLE_COND with a dyn_cast. + +2014-10-24 David Malcolm + Concretize gimple_cond_{true|false}_label * gimple.h (gimple_cond_true_label): Require a const_gimple_cond diff --git a/gcc/gimple.h b/gcc/gimple.h index 94f3416..1639579 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -3008,9 +3008,8 @@ gimple_cond_code (const_gimple gs) /* Set CODE to be the predicate code for the conditional statement GS. */ static inline void -gimple_cond_set_code (gimple gs, enum tree_code code) +gimple_cond_set_code (gimple_cond gs, enum tree_code code) { - GIMPLE_CHECK (gs, GIMPLE_COND); gs->subcode = code; } diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c index a7cbceb..6f6fef5 100644 --- a/gcc/tree-complex.c +++ b/gcc/tree-complex.c @@ -1405,9 +1405,12 @@ expand_complex_comparison (gimple_stmt_iterator *gsi, tree ar, tree ai, break; case GIMPLE_COND: - gimple_cond_set_code (stmt, EQ_EXPR); - gimple_cond_set_lhs (stmt, cc); - gimple_cond_set_rhs (stmt, boolean_true_node); + { + gimple_cond cond_stmt = as_a (stmt); + gimple_cond_set_code (cond_stmt, EQ_EXPR); + gimple_cond_set_lhs (cond_stmt, cc); + gimple_cond_set_rhs (cond_stmt, boolean_true_node); + } break; default: diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index 6715caa..a07d3a1 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -89,7 +89,7 @@ create_canonical_iv (struct loop *loop, edge exit, tree niter) { edge in; tree type, var; - gimple cond; + gimple_cond cond; gimple_stmt_iterator incr_at; enum tree_code cmp; @@ -100,7 +100,7 @@ create_canonical_iv (struct loop *loop, edge exit, tree niter) fprintf (dump_file, " iterations.\n"); } - cond = last_stmt (exit->src); + cond = as_a (last_stmt (exit->src)); in = EDGE_SUCC (exit->src, 0); if (in == exit) in = EDGE_SUCC (exit->src, 1); diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 57b63dc..76dc7d8 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -6480,9 +6480,10 @@ rewrite_use_compare (struct ivopts_data *data, loop_preheader_edge (data->current_loop), stmts); - gimple_cond_set_lhs (use->stmt, var); - gimple_cond_set_code (use->stmt, compare); - gimple_cond_set_rhs (use->stmt, op); + gimple_cond cond_stmt = as_a (use->stmt); + gimple_cond_set_lhs (cond_stmt, var); + gimple_cond_set_code (cond_stmt, compare); + gimple_cond_set_rhs (cond_stmt, op); return; } diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c index 9bd1a3b..bb3da81 100644 --- a/gcc/tree-ssa-loop-manip.c +++ b/gcc/tree-ssa-loop-manip.c @@ -1020,7 +1020,7 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor, transform_callback transform, void *data) { - gimple exit_if; + gimple_cond exit_if; tree ctr_before, ctr_after; tree enter_main_cond, exit_base, exit_step, exit_bound; enum tree_code exit_cmp; @@ -1217,7 +1217,7 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor, /* Finally create the new counter for number of iterations and add the new exit instruction. */ bsi = gsi_last_nondebug_bb (exit_bb); - exit_if = gsi_stmt (bsi); + exit_if = as_a (gsi_stmt (bsi)); create_iv (exit_base, exit_step, NULL_TREE, loop, &bsi, false, &ctr_before, &ctr_after); gimple_cond_set_code (exit_if, exit_cmp); @@ -1328,7 +1328,7 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch) tree type, var_before; gimple_stmt_iterator gsi; gimple_phi_iterator psi; - gimple stmt; + gimple_cond stmt; edge exit = single_dom_exit (loop); gimple_seq stmts; enum machine_mode mode; @@ -1379,7 +1379,7 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch) rewrite_all_phi_nodes_with_iv (loop, var_before); - stmt = last_stmt (exit->src); + stmt = as_a (last_stmt (exit->src)); /* Make the loop exit if the control condition is not satisfied. */ if (exit->flags & EDGE_TRUE_VALUE) { diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index 08482fd..200ee80 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -1445,14 +1445,14 @@ propagate_tree_value_into_stmt (gimple_stmt_iterator *gsi, tree val) propagate_tree_value (&expr, val); gimple_assign_set_rhs_from_tree (gsi, expr); } - else if (gimple_code (stmt) == GIMPLE_COND) + else if (gimple_cond cond_stmt = dyn_cast (stmt)) { tree lhs = NULL_TREE; tree rhs = build_zero_cst (TREE_TYPE (val)); propagate_tree_value (&lhs, val); - gimple_cond_set_code (stmt, NE_EXPR); - gimple_cond_set_lhs (stmt, lhs); - gimple_cond_set_rhs (stmt, rhs); + gimple_cond_set_code (cond_stmt, NE_EXPR); + gimple_cond_set_lhs (cond_stmt, lhs); + gimple_cond_set_rhs (cond_stmt, rhs); } else if (is_gimple_call (stmt) && gimple_call_lhs (stmt) != NULL_TREE)