Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.dg / gomp / pr68128-2.c
blob9720add11a93bd8831b7e557f77b46c7022c8d21
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);
8 void b1 (int, int);
10 int
11 f1 (void)
13 int a1 = 1;
14 unsigned char a2 = 2;
15 unsigned long a3 = 3;
16 long long a4 = 4;
17 short a5 = 5;
18 char a6 = 6;
19 #pragma omp parallel shared (a1, a2, a3)
21 if (omp_get_thread_num () == 0)
23 a1 = a2;
24 a4 = a5;
26 b1 (a2, a6);
27 #pragma omp barrier
28 if (omp_get_thread_num () == 1)
30 a1 += a3;
31 a4 += a6;
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);
48 void
49 f2 (void)
51 struct S a7 = { 7, 7 }, a8 = { 8, 8 };
52 int a9 = 9, a10 = 10;
53 short a11[2] = { 11, 11 };
54 char a12[1] = { 12 };
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);
70 _Complex float
71 f3 (void)
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;
82 b3 (a15, 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" } } */
93 int
94 f4 (void)
96 int a17 = 17, a18 = 18, a19 = 19, a20 = 20, a21 = 21, a22 = 22, a23 = 23, a24 = 0, a25 = 0, a26 = 0;
97 int i;
98 #pragma omp task shared (a17)
99 b1 (a17, a18);
100 b1 (a17, a18);
101 #pragma omp taskwait
102 #pragma omp parallel shared (a19)
104 #pragma omp task shared (a19)
106 a19 = 1;
108 #pragma omp task shared (a20)
109 a20 = a21;
110 #pragma omp for firstprivate (a25) lastprivate (a22) linear (a23:2) reduction (+:a24) private (a26)
111 for (i = 0; i < 10; i++)
113 a26 = i;
114 a22 = a26 + 7;
115 a23 += 2;
116 a24 += i;
117 a25++;
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" } } */
137 void
138 f5 (void)
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)
144 a27++;
145 #pragma omp parallel shared (a27, a28)
147 #pragma omp critical
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)
153 a28++;
154 a29++;
155 a30 = a29;
158 #pragma omp barrier
159 b1 (a27, a28);
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" } } */
170 f6 (void)
172 int a31 = 31, a32 = 32, a33 = 33, a34 = 34;
173 #pragma omp parallel
175 #pragma omp sections
177 #pragma omp section
179 a31 = 9;
181 #pragma omp section
183 int i = 10;
184 __builtin_memcpy (&a32, &i, sizeof (int));
187 #pragma omp single
188 a33 = 11;
189 #pragma omp atomic
190 a34++;
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" } } */