]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[og10] openacc: Unshare reduction temporaries for GCN
authorJulian Brown <julian@codesourcery.com>
Tue, 28 Jul 2020 13:02:50 +0000 (06:02 -0700)
committerJulian Brown <julian@codesourcery.com>
Thu, 30 Jul 2020 22:03:17 +0000 (15:03 -0700)
The GCN backend uses tree nodes like MEM((__lds TYPE *) <constant>)
for reduction temporaries. Unlike e.g. var decls and SSA names, these
nodes cannot be shared during gimplification, but are so in some
circumstances. This is detected when appropriate --enable-checking
options are used. This patch unshares such nodes when they are reused
more than once.

2020-07-30  Julian Brown  <julian@codesourcery.com>

gcc/
* config/gcn/gcn-tree.c (gcn_goacc_get_worker_red_decl): Do not
cache/share decls for reduction temporaries between invocations.
(gcn_goacc_reduction_teardown): Unshare VAR on second use.
* config/gcn/gcn.c (gcn_init_machine_status): Do not initialise
reduc_decls.
* config/gcn/gcn.h (machine_function): Remove reduc_decls cache.

gcc/ChangeLog.omp
gcc/config/gcn/gcn-tree.c
gcc/config/gcn/gcn.c
gcc/config/gcn/gcn.h

index 12b8c044a1b1645803da57193a68e5c08d975148..34622a3bfa1b091e6eac2f0b4749af53dc64c65f 100644 (file)
@@ -1,3 +1,12 @@
+2020-07-30  Julian Brown  <julian@codesourcery.com>
+
+       * config/gcn/gcn-tree.c (gcn_goacc_get_worker_red_decl): Do not
+       cache/share decls for reduction temporaries between invocations.
+       (gcn_goacc_reduction_teardown): Unshare VAR on second use.
+       * config/gcn/gcn.c (gcn_init_machine_status): Do not initialise
+       reduc_decls.
+       * config/gcn/gcn.h (machine_function): Remove reduc_decls cache.
+
 2020-07-30  Julian Brown  <julian@codesourcery.com>
 
        * config/gcn/gcn-tree.c (gcn_goacc_reduction_teardown): Remove useless
index bfde71555d8a6dd0054238b4624f4c90b52105f9..96fdf75a8cd95c19d1a84aa0d2c834e493d43273 100644 (file)
@@ -429,7 +429,6 @@ static tree
 gcn_goacc_get_worker_red_decl (tree type, unsigned offset)
 {
   machine_function *machfun = cfun->machine;
-  tree existing_decl;
 
   if (TREE_CODE (type) == REFERENCE_TYPE)
     type = TREE_TYPE (type);
@@ -439,29 +438,12 @@ gcn_goacc_get_worker_red_decl (tree type, unsigned offset)
                            (TYPE_QUALS (type)
                             | ENCODE_QUAL_ADDR_SPACE (ADDR_SPACE_LDS)));
 
-  if (machfun->reduc_decls
-      && offset < machfun->reduc_decls->length ()
-      && (existing_decl = (*machfun->reduc_decls)[offset]))
-    {
-      gcc_assert (TREE_TYPE (existing_decl) == var_type);
-      return existing_decl;
-    }
-  else
-    {
-      gcc_assert (offset
-                 < (machfun->reduction_limit - machfun->reduction_base));
-      tree ptr_type = build_pointer_type (var_type);
-      tree addr = build_int_cst (ptr_type, machfun->reduction_base + offset);
-
-      tree decl = build_simple_mem_ref (addr);
+  gcc_assert (offset
+             < (machfun->reduction_limit - machfun->reduction_base));
+  tree ptr_type = build_pointer_type (var_type);
+  tree addr = build_int_cst (ptr_type, machfun->reduction_base + offset);
 
-      vec_safe_grow_cleared (machfun->reduc_decls, offset + 1);
-      (*machfun->reduc_decls)[offset] = decl;
-
-      return decl;
-    }
-
-  return NULL_TREE;
+  return build_simple_mem_ref (addr);
 }
 
 /* Expand IFN_GOACC_REDUCTION_SETUP.  */
@@ -616,7 +598,7 @@ gcn_goacc_reduction_teardown (gcall *call)
     }
 
   if (lhs)
-    gimplify_assign (lhs, var, &seq);
+    gimplify_assign (lhs, unshare_expr (var), &seq);
 
   pop_gimplify_context (NULL);
 
index 4b2df3c7df061229f29aa7df0bbc9d41d849531e..028e5c577c073c5c1fd1b55ab0ae5e5403640957 100644 (file)
@@ -106,9 +106,6 @@ gcn_init_machine_status (void)
 
   f = ggc_cleared_alloc<machine_function> ();
 
-  /* And LDS temporary decls for worker reductions.  */
-  vec_alloc (f->reduc_decls, 0);
-
   if (TARGET_GCN3)
     f->use_flat_addressing = true;
 
index 91b3d88c062a09496f2f96ed49debaa32afaa11f..06475f59ad79b75eb06560eb8c7bfd229791a351 100644 (file)
@@ -573,7 +573,6 @@ struct GTY(()) machine_function
 
   unsigned HOST_WIDE_INT reduction_base;
   unsigned HOST_WIDE_INT reduction_limit;
-  vec<tree, va_gc> *reduc_decls;
 
   bool use_flat_addressing;
 };