[nvptx] Handle assignment to gang-level reduction variable
authorTom de Vries <tdevries@suse.de>
Tue, 15 Jan 2019 10:11:16 +0000 (10:11 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Tue, 15 Jan 2019 10:11:16 +0000 (10:11 +0000)
2019-01-15  Tom de Vries  <tdevries@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.

From-SVN: r267934

gcc/ChangeLog
gcc/config/nvptx/nvptx.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.oacc-c-c++-common/gang-reduction-var-assignment.c [new file with mode: 0644]

index 576541e5e3cc6f53beca5a409864f20deff43e4e..e45150933e093ec65981f21863d44a08bc61cc88 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-15  Tom de Vries  <tdevries@suse.de>
+
+       PR target/80547
+       * config/nvptx/nvptx.c (nvptx_goacc_reduction_init): Handle
+       lhs == NULL_TREE for gang-level reduction.
+
 2019-01-15  Richard Biener  <rguenther@suse.de>
            Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
 
index 03c0f82f4a2a7ea6cad4e38b26bf9d79928e3de4..23459e1c6f4744187657fcfbfeabdbea7a152f2e 100644 (file)
@@ -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);
index c279edfe2f36d58cf754abf8b21e549cb503de46..becfc701ad7bb857409cc3b8d1b2792bcd4aadd7 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-15  Tom de Vries  <tdevries@suse.de>
+
+       PR target/80547
+       * testsuite/libgomp.oacc-c-c++-common/gang-reduction-var-assignment.c:
+       New test.
+
 2019-01-12  Tom de Vries  <tdevries@suse.de>
 
        * testsuite/libgomp.oacc-c-c++-common/pr85486-2.c: New test.
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 (file)
index 0000000..05f58a4
--- /dev/null
@@ -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;
+}