libstdc++: remove JSON comment.
[official-gcc.git] / libgomp / testsuite / libgomp.c / scan-20.c
blob3ef88d78d9d30e551f6f8c11f0b4a088dac1d263
1 /* { dg-require-effective-target size32plus } */
2 /* { dg-additional-options "-O2 -fopenmp -fdump-tree-vect-details" } */
3 /* { dg-additional-options "-msse2" { target sse2_runtime } } */
4 /* { dg-additional-options "-mavx" { target avx_runtime } } */
5 /* { dg-final { scan-tree-dump-times "vectorized \[2-6] loops" 2 "vect" { target sse2_runtime } } } */
7 extern void abort (void);
8 int r, a[1024], b[1024], x, y, z;
10 __attribute__((noipa)) void
11 foo (int *a, int *b)
13 #pragma omp for simd reduction (inscan, +:r) lastprivate (conditional: z) firstprivate (x) private (y) simdlen(1)
14 for (int i = 0; i < 1024; i++)
16 { b[i] = r; if ((i & 1) == 0 && i < 937) z = r; }
17 #pragma omp scan exclusive(r)
18 { y = a[i]; r += y + x + 12; }
22 __attribute__((noipa)) int
23 bar (void)
25 int s = 0;
26 #pragma omp parallel
27 #pragma omp for simd reduction (inscan, +:s) firstprivate (x) private (y) lastprivate (z) if (0)
28 for (int i = 0; i < 1024; i++)
30 { y = s; b[i] = y + x + 12; }
31 #pragma omp scan exclusive(s)
32 { y = 2 * a[i]; s += y; z = y; }
34 return s;
37 __attribute__((noipa)) void
38 baz (int *a, int *b)
40 #pragma omp parallel for simd reduction (inscan, +:r) firstprivate (x) lastprivate (x)
41 for (int i = 0; i < 1024; i++)
43 b[i] = r;
44 #pragma omp scan exclusive(r)
45 { r += a[i]; if (i == 1023) x = 29; }
49 __attribute__((noipa)) int
50 qux (void)
52 int s = 0;
53 #pragma omp parallel for simd reduction (inscan, +:s) lastprivate (conditional: x, y)
54 for (int i = 0; i < 1024; i++)
56 { b[i] = s; if ((a[i] & 1) == 0 && i < 829) y = a[i]; }
57 #pragma omp scan exclusive(s)
58 { s += 2 * a[i]; if ((a[i] & 1) == 1 && i < 825) x = a[i]; }
60 return s;
63 int
64 main ()
66 int s = 0;
67 x = -12;
68 for (int i = 0; i < 1024; ++i)
70 a[i] = i;
71 b[i] = -1;
72 asm ("" : "+g" (i));
74 #pragma omp parallel
75 foo (a, b);
76 if (r != 1024 * 1023 / 2 || x != -12 || z != b[936])
77 abort ();
78 for (int i = 0; i < 1024; ++i)
80 if (b[i] != s)
81 abort ();
82 else
83 b[i] = 25;
84 s += i;
86 if (bar () != 1024 * 1023 || x != -12 || z != 2 * 1023)
87 abort ();
88 s = 0;
89 for (int i = 0; i < 1024; ++i)
91 if (b[i] != s)
92 abort ();
93 else
94 b[i] = -1;
95 s += 2 * i;
97 r = 0;
98 baz (a, b);
99 if (r != 1024 * 1023 / 2 || x != 29)
100 abort ();
101 s = 0;
102 for (int i = 0; i < 1024; ++i)
104 if (b[i] != s)
105 abort ();
106 else
107 b[i] = -25;
108 s += i;
110 if (qux () != 1024 * 1023 || x != 823 || y != 828)
111 abort ();
112 s = 0;
113 for (int i = 0; i < 1024; ++i)
115 if (b[i] != s)
116 abort ();
117 s += 2 * i;
119 return 0;