aboutsummaryrefslogtreecommitdiffstats
path: root/main/gcc/gcc10-pr91920.patch
blob: 001522c5d452777ae5ab9879a13982123120ca8f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
2019-09-27  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/91920
	* gimplify.c (omp_default_clause): Predetermine DECL_IN_CONSTANT_POOL
	variables as shared.

	* c-c++-common/gomp/pr91920.c: New test.

--- a/gcc/gimplify.c.jj	2019-09-20 12:25:46.829408105 +0200
+++ b/gcc/gimplify.c	2019-09-27 11:52:17.458446652 +0200
@@ -7132,6 +7132,8 @@ omp_default_clause (struct gimplify_omp_
   kind = lang_hooks.decls.omp_predetermined_sharing (decl);
   if (kind != OMP_CLAUSE_DEFAULT_UNSPECIFIED)
     default_kind = kind;
+  else if (VAR_P (decl) && TREE_STATIC (decl) && DECL_IN_CONSTANT_POOL (decl))
+    default_kind = OMP_CLAUSE_DEFAULT_SHARED;
 
   switch (default_kind)
     {
--- a/gcc/testsuite/c-c++-common/gomp/pr91920.c.jj	2019-09-27 11:57:26.066813061 +0200
+++ b/gcc/testsuite/c-c++-common/gomp/pr91920.c	2019-09-27 11:57:08.931070237 +0200
@@ -0,0 +1,19 @@
+/* PR middle-end/91920 */
+
+void bar (float *);
+
+void
+foo (void)
+{
+  int i;
+  float f[3] = { 0.0f, 0.0f, 0.0f };
+#pragma omp parallel for default(none) reduction(+:f[:3])
+  for (i = 0; i < 1000; i++)
+    {
+      int j;
+      float k[3] = { 0.25f, 0.5f, 0.75f };
+      for (j = 0; j < 3; j++)
+	f[j] += k[j];
+    }
+  bar (f);
+}