Hi, this fixes an ICE when handling an assignment to a gang-level reduction variable.
Committed to trunk. Thanks, - Tom [nvptx] Handle assignment to gang-level reduction variable 2019-01-15 Tom de Vries <tdevr...@suse.de> PR target/80547 * config/nvptx/nvptx.c (nvptx_goacc_reduction_init): Handle lhs == NULL_TREE for gang-level reduction. * testsuite/libgomp.oacc-c-c++-common/gang-reduction-var-assignment.c: New test. --- gcc/config/nvptx/nvptx.c | 3 ++- .../gang-reduction-var-assignment.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 03c0f82f4a2..23459e1c6f4 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -6242,7 +6242,8 @@ nvptx_goacc_reduction_init (gcall *call, offload_attrs *oa) init = var; } - gimplify_assign (lhs, init, &seq); + if (lhs != NULL_TREE) + gimplify_assign (lhs, init, &seq); } pop_gimplify_context (NULL); diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/gang-reduction-var-assignment.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/gang-reduction-var-assignment.c new file mode 100644 index 00000000000..05f58a4bddf --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/gang-reduction-var-assignment.c @@ -0,0 +1,16 @@ +/* { dg-xfail-run-if "PR88852" { openacc_host_selected } } */ + +int +main (void) +{ + int x = 123; + +#pragma acc parallel num_gangs(1) reduction (+: x) + { + x = 23; + } + if (x != 146) + __builtin_abort(); + + return 0; +}