public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Schwinge <thomas@codesourcery.com>
To: Jakub Jelinek <jakub@redhat.com>, GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Nathan Sidwell <nathan@codesourcery.com>
Subject: Refactor omp_reduction_init: omp_reduction_init_op (was: [gomp4] ptx reduction simplification)
Date: Wed, 23 Sep 2015 14:16:00 -0000	[thread overview]
Message-ID: <87si65xm4y.fsf@kepler.schwinge.homeip.net> (raw)
In-Reply-To: <56016FBF.1070604@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 4539 bytes --]

Hi!

On Tue, 22 Sep 2015 11:11:59 -0400, Nathan Sidwell <nathan@codesourcery.com> wrote:
> On 09/22/15 11:10, Thomas Schwinge wrote:
> > On Fri, 18 Sep 2015 20:05:48 -0400, Nathan Sidwell <nathan@acm.org> wrote:
> >> 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.)
> 
> go  for it!

Tested on x86_64-pc-linux-gnu; no changes.  OK for trunk?

commit de2726ef46b8d875239ccb445c784c56e1a716dc
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Tue Sep 22 17:30:40 2015 +0200

    Refactor omp_reduction_init: omp_reduction_init_op
    
    2015-09-23  Thomas Schwinge  <thomas@codesourcery.com>
    	    Nathan Sidwell  <nathan@codesourcery.com>
    
    	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_context *ctx)
 }
 
 
-/* Construct the initialization value for reduction CLAUSE.  */
+/* Construct the initialization value for reduction operation OP.  */
 
 tree
-omp_reduction_init (tree clause, tree type)
+omp_reduction_init_op (location_t loc, enum tree_code op, tree type)
 {
-  location_t loc = 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)
     }
 }
 
+/* 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.  */
 
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;
 
   struct reduction_info *const reduc = *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.  */
 
-  /* Create a new variable to initialize the reduction.  */
+  /* Initialize the reduction.  */
   type = TREE_TYPE (PHI_RESULT (reduc->reduc_phi));
-  bvar = create_tmp_var (type, "reduction");
-
-  c = build_omp_clause (gimple_location (reduc->reduc_stmt),
-			OMP_CLAUSE_REDUCTION);
-  OMP_CLAUSE_REDUCTION_CODE (c) = reduc->reduction_code;
-  OMP_CLAUSE_DECL (c) = SSA_NAME_VAR (reduc_stmt_res (reduc->reduc_stmt));
-
-  init = omp_reduction_init (c, TREE_TYPE (bvar));
+  init = omp_reduction_init_op (gimple_location (reduc->reduc_stmt),
+				reduc->reduction_code, type);
   reduc->init = init;
 
   /* Replace the argument representing the initialization value


Grüße,
 Thomas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

  reply	other threads:[~2015-09-23 14:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-19  2:30 [gomp4] ptx reduction simplification Nathan Sidwell
2015-09-22 15:12 ` Thomas Schwinge
2015-09-22 15:16   ` Nathan Sidwell
2015-09-23 14:16     ` Thomas Schwinge [this message]
2015-09-23 14:19       ` Refactor omp_reduction_init: omp_reduction_init_op Bernd Schmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87si65xm4y.fsf@kepler.schwinge.homeip.net \
    --to=thomas@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=nathan@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).