]> 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)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Thu, 22 Apr 2021 17:14:27 +0000 (10:14 -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 b1bc945898a4ddd30d3101cd8d8cb8199f44d28f..29bcb59eff5f4cc8b477a12ec237ca08b5de9746 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 58a45e5c5a4a8232c07329a3fedce1722b763de1..4f339a8864c974c04192a35dcfbf5fb9351bd74e 100644 (file)
@@ -310,7 +310,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);
@@ -320,29 +319,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, true);
-      (*machfun->reduc_decls)[offset] = decl;
-
-      return decl;
-    }
-
-  return NULL_TREE;
+  return build_simple_mem_ref (addr);
 }
 
 /* Expand IFN_GOACC_REDUCTION_SETUP.  */
@@ -497,7 +479,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 80f1430cca8dafca1cf4822858e90dba27b6a3cd..66599afb48750ae79019020cd5c7b08e4fe16a19 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 5ea075fcd7e4905c77325e164a82098dc943eb70..cf8fcb4ef74852d23290e6392709dd483fb0387a 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;
 };