From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28699 invoked by alias); 23 Sep 2015 14:10:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 28690 invoked by uid 89); 23 Sep 2015 14:10:08 -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,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Sep 2015 14:10:05 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ZekkD-0006wl-Pr from Thomas_Schwinge@mentor.com ; Wed, 23 Sep 2015 07:10:02 -0700 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Wed, 23 Sep 2015 15:10:00 +0100 From: Thomas Schwinge To: Jakub Jelinek , GCC Patches CC: Nathan Sidwell Subject: Refactor omp_reduction_init: omp_reduction_init_op (was: [gomp4] ptx reduction simplification) In-Reply-To: <56016FBF.1070604@codesourcery.com> References: <55FCA6DC.1040802@acm.org> <87k2rizdzi.fsf@kepler.schwinge.homeip.net> <56016FBF.1070604@codesourcery.com> User-Agent: Notmuch/0.9-125-g4686d11 (http://notmuchmail.org) Emacs/24.5.1 (i586-pc-linux-gnu) Date: Wed, 23 Sep 2015 14:16:00 -0000 Message-ID: <87si65xm4y.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-SW-Source: 2015-09/txt/msg01753.txt.bz2 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 4483 Hi! On Tue, 22 Sep 2015 11:11:59 -0400, Nathan Sidwell wrote: > On 09/22/15 11:10, Thomas Schwinge wrote: > > On Fri, 18 Sep 2015 20:05:48 -0400, Nathan Sidwell wro= te: > >> I've committed this patch to rework and simplify [...] > >> the reduction lowering hooks. > >> > >> The current implementation [...] > >> [was] overcomplicated in a number of ways. > > > >> * omp-low.h (omp_reduction_init_op): Declare. > >> * omp-low.c (omp_reduction_init_op): New, broken out of ... > >> (omp_reduction_init): ... here. Call it. > >> * tree-parloops.c (initialize_reductions): Use > >> omp_redutction_init_op. > > > > Should this go into trunk already? (I can test it, if you'd like me to= .) >=20 > go for it! Tested on x86_64-pc-linux-gnu; no changes. OK for trunk? commit de2726ef46b8d875239ccb445c784c56e1a716dc Author: Thomas Schwinge Date: Tue Sep 22 17:30:40 2015 +0200 Refactor omp_reduction_init: omp_reduction_init_op =20=20=20=20 2015-09-23 Thomas Schwinge Nathan Sidwell =20=20=20=20 gcc/ * omp-low.h (omp_reduction_init_op): Declare. * omp-low.c (omp_reduction_init_op): New, broken out of ... (omp_reduction_init): ... here. Call it. * tree-parloops.c (initialize_reductions): Use omp_reduction_init_op. --- gcc/omp-low.c | 16 ++++++++++++---- gcc/omp-low.h | 1 + gcc/tree-parloops.c | 16 +++++----------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git gcc/omp-low.c gcc/omp-low.c index 88a5149..fae407d 100644 --- gcc/omp-low.c +++ gcc/omp-low.c @@ -3372,13 +3372,12 @@ maybe_lookup_decl_in_outer_ctx (tree decl, omp_cont= ext *ctx) } =20 =20 -/* Construct the initialization value for reduction CLAUSE. */ +/* Construct the initialization value for reduction operation OP. */ =20 tree -omp_reduction_init (tree clause, tree type) +omp_reduction_init_op (location_t loc, enum tree_code op, tree type) { - location_t loc =3D OMP_CLAUSE_LOCATION (clause); - switch (OMP_CLAUSE_REDUCTION_CODE (clause)) + switch (op) { case PLUS_EXPR: case MINUS_EXPR: @@ -3451,6 +3450,15 @@ omp_reduction_init (tree clause, tree type) } } =20 +/* Construct the initialization value for reduction CLAUSE. */ + +tree +omp_reduction_init (tree clause, tree type) +{ + return omp_reduction_init_op (OMP_CLAUSE_LOCATION (clause), + OMP_CLAUSE_REDUCTION_CODE (clause), type); +} + /* Return alignment to be assumed for var in CLAUSE, which should be OMP_CLAUSE_ALIGNED. */ =20 diff --git gcc/omp-low.h gcc/omp-low.h index 8a4052e..44e35a3 100644 --- gcc/omp-low.h +++ gcc/omp-low.h @@ -25,6 +25,7 @@ struct omp_region; extern tree find_omp_clause (tree, enum omp_clause_code); extern void omp_expand_local (basic_block); extern void free_omp_regions (void); +extern tree omp_reduction_init_op (location_t, enum tree_code, tree); extern tree omp_reduction_init (tree, tree); extern bool make_gimple_omp_edges (basic_block, struct omp_region **, int = *); extern void omp_finish_file (void); diff --git gcc/tree-parloops.c gcc/tree-parloops.c index c164121..94cacb6 100644 --- gcc/tree-parloops.c +++ gcc/tree-parloops.c @@ -565,8 +565,8 @@ reduc_stmt_res (gimple stmt) int initialize_reductions (reduction_info **slot, struct loop *loop) { - tree init, c; - tree bvar, type, arg; + tree init; + tree type, arg; edge e; =20 struct reduction_info *const reduc =3D *slot; @@ -577,16 +577,10 @@ initialize_reductions (reduction_info **slot, struct = loop *loop) /* In the phi node at the header, replace the argument coming from the preheader with the reduction initialization value. */ =20 - /* Create a new variable to initialize the reduction. */ + /* Initialize the reduction. */ type =3D TREE_TYPE (PHI_RESULT (reduc->reduc_phi)); - bvar =3D create_tmp_var (type, "reduction"); - - c =3D build_omp_clause (gimple_location (reduc->reduc_stmt), - OMP_CLAUSE_REDUCTION); - OMP_CLAUSE_REDUCTION_CODE (c) =3D reduc->reduction_code; - OMP_CLAUSE_DECL (c) =3D SSA_NAME_VAR (reduc_stmt_res (reduc->reduc_stmt)= ); - - init =3D omp_reduction_init (c, TREE_TYPE (bvar)); + init =3D omp_reduction_init_op (gimple_location (reduc->reduc_stmt), + reduc->reduction_code, type); reduc->init =3D init; =20 /* Replace the argument representing the initialization value Gr=C3=BC=C3=9Fe, Thomas --=-=-= Content-Type: application/pgp-signature; name="signature.asc" Content-length: 472 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJWArKtAAoJEK3/DN1sMFFtwvcIAK2W2L1yB6mqyKIISfIm12U+ 2oQS9v2hZBgeMOMldaMDWVVT1RaA8h/P652CMmfu3cdfiPoVE4zigsEH5RSKgXxd dUdzSysP7ODvmY0hmPh3jaMIyrw1P04h5FCta8+WqegQTvdWHRYyWkItjNjVQTcQ /Mrp2xjW4amaizsuYr2KFVb8MhDdc60KyXW/BM6w7YJXAv3z0kGzZmx0v2gSHVqP q/R0Gue3htbu1qSc8osqPN5Jxi6FBv+HQSTE2+KDzlo54IvTzwFKXQoyopx8lOHj qplt9N5P4HTri9kR+C9bb4rmOFgOY5IKd477dOEOS8P3/h+635sSgZDCqbrhUB8= =QBGm -----END PGP SIGNATURE----- --=-=-=--