Refactor omp_reduction_init: omp_reduction_init_op
authorThomas Schwinge <thomas@codesourcery.com>
Wed, 23 Sep 2015 14:46:55 +0000 (16:46 +0200)
committerThomas Schwinge <tschwinge@gcc.gnu.org>
Wed, 23 Sep 2015 14:46:55 +0000 (16:46 +0200)
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.

Co-Authored-By: Nathan Sidwell <nathan@codesourcery.com>
From-SVN: r228052

gcc/ChangeLog
gcc/omp-low.c
gcc/omp-low.h
gcc/tree-parloops.c

index f6aa3a05f82a6023efd35cc36f881d1757592a5e..0e9b728e6e5df70fc5ee7e560b1ec12dfd9e3c93 100644 (file)
@@ -1,3 +1,12 @@
+2015-09-23  Thomas Schwinge  <thomas@codesourcery.com>
+           Nathan Sidwell  <nathan@codesourcery.com>
+
+       * 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.
+
 2015-09-23   Richard Biener  <rguenther@suse.de>
 
        PR middle-end/67662
index 7c92c94c9a45d93f48b9ca68f62c7cd246177e0a..cb007582cf29d8ee8375c4c863bdc058bdd951d9 100644 (file)
@@ -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.  */
 
index 8a4052efcadadabea8820fd5575dc5e871eca3e9..44e35a3591896fc7f7e34aa89bb2092c4afbce11 100644 (file)
@@ -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);
index 8deddb1d775169b7d1dc26362903a7f2f35c02cc..741392bf937c74694112fd71972c414f14f1ebfb 100644 (file)
@@ -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