1 /* { dg-require-effective-target size32plus } */
2
3 extern void abort (void);
4 int r, a[1024], b[1024], x, y, z;
5
6 __attribute__((noipa)) void
foo(int * a,int * b)7 foo (int *a, int *b)
8 {
9 #pragma omp for reduction (inscan, +:r) lastprivate (conditional: z) firstprivate (x) private (y)
10 for (int i = 0; i < 1024; i++)
11 {
12 { b[i] = r; if ((i & 1) == 0 && i < 937) z = r; }
13 #pragma omp scan exclusive(r)
14 { y = a[i]; r += y + x + 12; }
15 }
16 }
17
18 __attribute__((noipa)) int
bar(void)19 bar (void)
20 {
21 int s = 0;
22 #pragma omp parallel
23 #pragma omp for reduction (inscan, +:s) firstprivate (x) private (y) lastprivate (z)
24 for (int i = 0; i < 1024; i++)
25 {
26 { y = s; b[i] = y + x + 12; }
27 #pragma omp scan exclusive(s)
28 { y = 2 * a[i]; s += y; z = y; }
29 }
30 return s;
31 }
32
33 __attribute__((noipa)) void
baz(int * a,int * b)34 baz (int *a, int *b)
35 {
36 #pragma omp parallel for reduction (inscan, +:r) firstprivate (x) lastprivate (x)
37 for (int i = 0; i < 1024; i++)
38 {
39 b[i] = r;
40 #pragma omp scan exclusive(r)
41 { r += a[i] + x + 12; if (i == 1023) x = 29; }
42 }
43 }
44
45 __attribute__((noipa)) int
qux(void)46 qux (void)
47 {
48 int s = 0;
49 #pragma omp parallel for reduction (inscan, +:s) lastprivate (conditional: x, y)
50 for (int i = 0; i < 1024; i++)
51 {
52 { b[i] = s; if ((a[i] & 1) == 0 && i < 829) y = a[i]; }
53 #pragma omp scan exclusive(s)
54 { s += 2 * a[i]; if ((a[i] & 1) == 1 && i < 825) x = a[i]; }
55 }
56 return s;
57 }
58
59 int
main()60 main ()
61 {
62 int s = 0;
63 x = -12;
64 for (int i = 0; i < 1024; ++i)
65 {
66 a[i] = i;
67 b[i] = -1;
68 asm ("" : "+g" (i));
69 }
70 #pragma omp parallel
71 foo (a, b);
72 if (r != 1024 * 1023 / 2 || x != -12 || z != b[936])
73 abort ();
74 for (int i = 0; i < 1024; ++i)
75 {
76 if (b[i] != s)
77 abort ();
78 else
79 b[i] = 25;
80 s += i;
81 }
82 if (bar () != 1024 * 1023 || x != -12 || z != 2 * 1023)
83 abort ();
84 s = 0;
85 for (int i = 0; i < 1024; ++i)
86 {
87 if (b[i] != s)
88 abort ();
89 else
90 b[i] = -1;
91 s += 2 * i;
92 }
93 r = 0;
94 baz (a, b);
95 if (r != 1024 * 1023 / 2 || x != 29)
96 abort ();
97 s = 0;
98 for (int i = 0; i < 1024; ++i)
99 {
100 if (b[i] != s)
101 abort ();
102 else
103 b[i] = -25;
104 s += i;
105 }
106 if (qux () != 1024 * 1023 || x != 823 || y != 828)
107 abort ();
108 s = 0;
109 for (int i = 0; i < 1024; ++i)
110 {
111 if (b[i] != s)
112 abort ();
113 s += 2 * i;
114 }
115 return 0;
116 }
117