1 /* PR tree-optimization/68128 */
2 /* { dg-do compile } */
3 /* { dg-additional-options "-O2 -fdump-tree-omplower" } */
5 extern int omp_get_thread_num (void);
6 extern int omp_get_ancestor_thread_num (int);
19 #pragma omp parallel shared (a1, a2, a3)
21 if (omp_get_thread_num () == 0)
28 if (omp_get_thread_num () == 1)
34 return a1
+ a2
+ a3
+ a4
+ a5
+ a6
;
37 /* { dg-final { scan-tree-dump "shared\\(a1\\)" "omplower" } } */
38 /* { dg-final { scan-tree-dump "firstprivate\\(a2\\)" "omplower" } } */
39 /* { dg-final { scan-tree-dump "firstprivate\\(a3\\)" "omplower" } } */
40 /* { dg-final { scan-tree-dump "shared\\(a4\\)" "omplower" } } */
41 /* { dg-final { scan-tree-dump "firstprivate\\(a5\\)" "omplower" } } */
42 /* { dg-final { scan-tree-dump "firstprivate\\(a6\\)" "omplower" } } */
44 struct S
{ int a
, b
; };
46 void b2 (int *, int *, int, int, struct S
, struct S
);
51 struct S a7
= { 7, 7 }, a8
= { 8, 8 };
53 short a11
[2] = { 11, 11 };
55 #pragma omp parallel shared (a7, a9, a11)
57 b2 (&a9
, &a10
, a11
[1], a12
[0], a7
, a8
);
61 /* { dg-final { scan-tree-dump "shared\\(a7\\)" "omplower" } } */
62 /* { dg-final { scan-tree-dump "shared\\(a8\\)" "omplower" } } */
63 /* { dg-final { scan-tree-dump "shared\\(a9\\)" "omplower" } } */
64 /* { dg-final { scan-tree-dump "shared\\(a10\\)" "omplower" } } */
65 /* { dg-final { scan-tree-dump "shared\\(a11\\)" "omplower" } } */
66 /* { dg-final { scan-tree-dump "shared\\(a12\\)" "omplower" } } */
68 void b3 (_Complex
float, _Complex
float);
73 _Complex
float a13
= 13.0f
, a14
= 14.0f
, a15
= 15.0f
, a16
= 16.0f
;
74 #pragma omp parallel shared (a13, a15)
76 #pragma omp parallel shared (a14)
78 if (omp_get_thread_num () == 0 && omp_get_ancestor_thread_num (1) == 1)
79 __imag__ a13
= __real__ a15
;
80 else if (omp_get_thread_num () == 1 && omp_get_ancestor_thread_num (1) == 0)
81 __real__ a14
= __imag__ a16
;
85 return a13
+ a14
+ a15
+ a16
;
88 /* { dg-final { scan-tree-dump-times "shared\\(a13\\)" 2 "omplower" } } */
89 /* { dg-final { scan-tree-dump-times "shared\\(a14\\)" 2 "omplower" } } */
90 /* { dg-final { scan-tree-dump-times "firstprivate\\(a15\\)" 2 "omplower" } } */
91 /* { dg-final { scan-tree-dump-times "firstprivate\\(a16\\)" 2 "omplower" } } */
96 int a17
= 17, a18
= 18, a19
= 19, a20
= 20, a21
= 21, a22
= 22, a23
= 23, a24
= 0, a25
= 0, a26
= 0;
98 #pragma omp task shared (a17)
102 #pragma omp parallel shared (a19)
104 #pragma omp task shared (a19)
108 #pragma omp task shared (a20)
110 #pragma omp for firstprivate (a25) lastprivate (a22) linear (a23:2) reduction (+:a24) private (a26)
111 for (i
= 0; i
< 10; i
++)
120 return a22
+ a23
+ a24
+ a25
+ a26
;
123 /* { dg-final { scan-tree-dump "firstprivate\\(a17\\)" "omplower" } } */
124 /* { dg-final { scan-tree-dump "firstprivate\\(a18\\)" "omplower" } } */
125 /* { dg-final { scan-tree-dump-times "shared\\(a19\\)" 2 "omplower" } } */
126 /* { dg-final { scan-tree-dump-times "shared\\(a20\\)" 2 "omplower" } } */
127 /* { dg-final { scan-tree-dump-times "firstprivate\\(a21\\)" 2 "omplower" } } */
128 /* { dg-final { scan-tree-dump-times "lastprivate\\(a22\\)" 1 "omplower" } } */
129 /* { dg-final { scan-tree-dump-times "shared\\(a22\\)" 1 "omplower" } } */
130 /* { dg-final { scan-tree-dump-times "linear\\(a23:2\\)" 1 "omplower" } } */
131 /* { dg-final { scan-tree-dump-times "shared\\(a23\\)" 1 "omplower" } } */
132 /* { dg-final { scan-tree-dump-times "reduction\\(.:a24\\)" 1 "omplower" } } */
133 /* { dg-final { scan-tree-dump-times "shared\\(a24\\)" 1 "omplower" } } */
134 /* { dg-final { scan-tree-dump-times "firstprivate\\(a25\\)" 2 "omplower" } } */
135 /* { dg-final { scan-tree-dump-times "private\\(a26\\)" 1 "omplower" } } */
140 int a27
= 27, a28
= 28, a29
= 29, a30
= 30;
141 #pragma omp target data map (tofrom: a27, a28)
143 #pragma omp target map (tofrom: a27)
145 #pragma omp parallel shared (a27, a28)
149 /* This might modify a27 for non-shared memory offloading. */
150 #pragma omp target update to (a27)
151 #pragma omp target map (always, from: a28) private (a30)
164 /* { dg-final { scan-tree-dump "shared\\(a27\\)" "omplower" } } */
165 /* { dg-final { scan-tree-dump "shared\\(a28\\)" "omplower" } } */
166 /* { dg-final { scan-tree-dump-times "firstprivate\\(a29\\)" 2 "omplower" } } */
167 /* { dg-final { scan-tree-dump-times "private\\(a30\\)" 1 "omplower" } } */
172 int a31
= 31, a32
= 32, a33
= 33, a34
= 34;
184 __builtin_memcpy (&a32
, &i
, sizeof (int));
192 return a31
+ a32
+ a33
+ a34
;
195 /* { dg-final { scan-tree-dump "shared\\(a31\\)" "omplower" } } */
196 /* { dg-final { scan-tree-dump "shared\\(a32\\)" "omplower" } } */
197 /* { dg-final { scan-tree-dump "shared\\(a33\\)" "omplower" } } */
198 /* { dg-final { scan-tree-dump "shared\\(a34\\)" "omplower" } } */