public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-11] [og10] openacc: Unshare reduction temporaries for GCN
@ 2021-05-13 16:16 Kwok Yeung
0 siblings, 0 replies; only message in thread
From: Kwok Yeung @ 2021-05-13 16:16 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3d7114a04e08fec75d1e1635fbd8f38ed6f7b701
commit 3d7114a04e08fec75d1e1635fbd8f38ed6f7b701
Author: Julian Brown <julian@codesourcery.com>
Date: Tue Jul 28 06:02:50 2020 -0700
[og10] openacc: Unshare reduction temporaries for GCN
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.
Diff:
---
gcc/ChangeLog.omp | 9 +++++++++
gcc/config/gcn/gcn-tree.c | 30 ++++++------------------------
gcc/config/gcn/gcn.c | 3 ---
gcc/config/gcn/gcn.h | 1 -
4 files changed, 15 insertions(+), 28 deletions(-)
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index b1bc945898a..29bcb59eff5 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -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
diff --git a/gcc/config/gcn/gcn-tree.c b/gcc/config/gcn/gcn-tree.c
index 58a45e5c5a4..4f339a8864c 100644
--- a/gcc/config/gcn/gcn-tree.c
+++ b/gcc/config/gcn/gcn-tree.c
@@ -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);
diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c
index 80f1430cca8..66599afb487 100644
--- a/gcc/config/gcn/gcn.c
+++ b/gcc/config/gcn/gcn.c
@@ -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;
diff --git a/gcc/config/gcn/gcn.h b/gcc/config/gcn/gcn.h
index 5ea075fcd7e..cf8fcb4ef74 100644
--- a/gcc/config/gcn/gcn.h
+++ b/gcc/config/gcn/gcn.h
@@ -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;
};
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-13 16:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13 16:16 [gcc/devel/omp/gcc-11] [og10] openacc: Unshare reduction temporaries for GCN Kwok Yeung
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).