From patchwork Mon Apr 21 16:57:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 340974 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 1D9081400CF for ; Tue, 22 Apr 2014 12:42:42 +1000 (EST) 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=uyvWRrmql+uk/kH2KEGHV600U26cJJddM2NEKeMq74bNXmryicPKy jR1IJI/BEHEAgBGT0PYlHZpBGEcz9RgQb7M61GOSP+CbbAb0ucI15QjuJ57nd9PZ VcmlprdV3lJdE3oXEPVUy9WOjUtPikBD7GL640Rz0VYxn46fR9vzHI= 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=ITJ+8eY/Eq0Tedhfd+to6ZXkDGU=; b=gt/vEMxEg8JXSXRkto92 k4Tnhuv3AonXzOpN5ruN1qLtNgFVp07s+kAym/SB311/YukOkR5IPlgqotjdvfd1 /UN2ce9sccePc80+rhlSfaCn0q4+MLwzgtFYmX8538MYRCSKwvimUe/4q4wGF4Ky MZevFgjYtpxKc4BVThl6gQ4= Received: (qmail 19111 invoked by alias); 21 Apr 2014 17:12:15 -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 19084 invoked by uid 89); 21 Apr 2014 17:12:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 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; Mon, 21 Apr 2014 17:12:14 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WcHXI-0002Qu-Vx for gcc-patches@gcc.gnu.org; Mon, 21 Apr 2014 12:57:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18125) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcHXI-0002Qg-Nw for gcc-patches@gcc.gnu.org; Mon, 21 Apr 2014 12:57:40 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3LGud9J023256 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 21 Apr 2014 12:56:39 -0400 Received: from c64.redhat.com (vpn-227-164.phx2.redhat.com [10.3.227.164]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3LGtvOR023014; Mon, 21 Apr 2014 12:56:38 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 66/89] Make gimple_phi_arg_location_from_edge require a gimple_phi Date: Mon, 21 Apr 2014 12:57:37 -0400 Message-Id: <1398099480-49147-67-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1398099480-49147-1-git-send-email-dmalcolm@redhat.com> References: <1398099480-49147-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/ * gimple.h (gimple_phi_arg_location_from_edge): Require a gimple_phi. * tree-parloops.c (create_parallel_loop): Split up local variable "stmt", introducing other locals for the various statements created by this function. Reuse "stmt" within the phi-handling code, and change to type gimple_phi, since this is the only remaining "non-phi" user of gimple_phi_arg_location_from_edge. --- gcc/gimple.h | 6 +++--- gcc/tree-parloops.c | 46 +++++++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/gcc/gimple.h b/gcc/gimple.h index 788e8c7..becd273 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -4258,12 +4258,12 @@ gimple_phi_arg_location (gimple gs, size_t i) return gimple_phi_arg (gs, i)->locus; } -/* Return the source location of the argument on edge E of phi node GS. */ +/* Return the source location of the argument on edge E of phi node PHI. */ static inline source_location -gimple_phi_arg_location_from_edge (gimple gs, edge e) +gimple_phi_arg_location_from_edge (gimple_phi phi, edge e) { - return gimple_phi_arg (gs, e->dest_idx)->locus; + return gimple_phi_arg (phi, e->dest_idx)->locus; } /* Set the source location of gimple argument I of phi node PHI to LOC. */ diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index c85baf1..94af311 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -1622,8 +1622,11 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data, gimple_stmt_iterator gsi; basic_block bb, paral_bb, for_bb, ex_bb; tree t, param; - gimple stmt, phi, cond_stmt; + gimple_omp_parallel omp_par_stmt; + gimple omp_return_stmt1, omp_return_stmt2; + gimple phi, cond_stmt; gimple_omp_for for_stmt; + gimple_omp_continue omp_cont_stmt; tree cvar, cvar_init, initvar, cvar_next, cvar_base, type; edge exit, nexit, guard, end, e; @@ -1635,31 +1638,33 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data, t = build_omp_clause (loc, OMP_CLAUSE_NUM_THREADS); OMP_CLAUSE_NUM_THREADS_EXPR (t) = build_int_cst (integer_type_node, n_threads); - stmt = gimple_build_omp_parallel (NULL, t, loop_fn, data); - gimple_set_location (stmt, loc); + omp_par_stmt = gimple_build_omp_parallel (NULL, t, loop_fn, data); + gimple_set_location (omp_par_stmt, loc); - gsi_insert_after (&gsi, stmt, GSI_NEW_STMT); + gsi_insert_after (&gsi, omp_par_stmt, GSI_NEW_STMT); /* Initialize NEW_DATA. */ if (data) { + gimple_assign assign_stmt; + gsi = gsi_after_labels (bb); param = make_ssa_name (DECL_ARGUMENTS (loop_fn), NULL); - stmt = gimple_build_assign (param, build_fold_addr_expr (data)); - gsi_insert_before (&gsi, stmt, GSI_SAME_STMT); + assign_stmt = gimple_build_assign (param, build_fold_addr_expr (data)); + gsi_insert_before (&gsi, assign_stmt, GSI_SAME_STMT); - stmt = gimple_build_assign (new_data, + assign_stmt = gimple_build_assign (new_data, fold_convert (TREE_TYPE (new_data), param)); - gsi_insert_before (&gsi, stmt, GSI_SAME_STMT); + gsi_insert_before (&gsi, assign_stmt, GSI_SAME_STMT); } /* Emit GIMPLE_OMP_RETURN for GIMPLE_OMP_PARALLEL. */ bb = split_loop_exit_edge (single_dom_exit (loop)); gsi = gsi_last_bb (bb); - stmt = gimple_build_omp_return (false); - gimple_set_location (stmt, loc); - gsi_insert_after (&gsi, stmt, GSI_NEW_STMT); + omp_return_stmt1 = gimple_build_omp_return (false); + gimple_set_location (omp_return_stmt1, loc); + gsi_insert_after (&gsi, omp_return_stmt1, GSI_NEW_STMT); /* Extract data for GIMPLE_OMP_FOR. */ gcc_assert (loop->header == single_dom_exit (loop)->src); @@ -1693,7 +1698,10 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data, source_location locus; tree def; gimple_phi phi = gpi.phi (); - stmt = SSA_NAME_DEF_STMT (PHI_ARG_DEF_FROM_EDGE (phi, exit)); + gimple_phi stmt; + + stmt = SSA_NAME_DEF_STMT (PHI_ARG_DEF_FROM_EDGE (phi, exit)) + ->as_a_gimple_phi (); def = PHI_ARG_DEF_FROM_EDGE (stmt, loop_preheader_edge (loop)); locus = gimple_phi_arg_location_from_edge (stmt, @@ -1729,16 +1737,16 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data, /* Emit GIMPLE_OMP_CONTINUE. */ gsi = gsi_last_bb (loop->latch); - stmt = gimple_build_omp_continue (cvar_next, cvar); - gimple_set_location (stmt, loc); - gsi_insert_after (&gsi, stmt, GSI_NEW_STMT); - SSA_NAME_DEF_STMT (cvar_next) = stmt; + omp_cont_stmt = gimple_build_omp_continue (cvar_next, cvar); + gimple_set_location (omp_cont_stmt, loc); + gsi_insert_after (&gsi, omp_cont_stmt, GSI_NEW_STMT); + SSA_NAME_DEF_STMT (cvar_next) = omp_cont_stmt; /* Emit GIMPLE_OMP_RETURN for GIMPLE_OMP_FOR. */ gsi = gsi_last_bb (ex_bb); - stmt = gimple_build_omp_return (true); - gimple_set_location (stmt, loc); - gsi_insert_after (&gsi, stmt, GSI_NEW_STMT); + omp_return_stmt2 = gimple_build_omp_return (true); + gimple_set_location (omp_return_stmt2, loc); + gsi_insert_after (&gsi, omp_return_stmt2, GSI_NEW_STMT); /* After the above dom info is hosed. Re-compute it. */ free_dominance_info (CDI_DOMINATORS);