AVR: Assert minimal required bit width of section_common::flags.
[gcc.git] / libgomp / testsuite / libgomp.c / scan-19.c
blobb4205012902aa808dc074981102e0cee66ec6d2a
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)
14 for (int i = 0; i < 1024; i++)
16 { y = a[i]; r += y + x + 12; }
17 #pragma omp scan inclusive(r)
18 { b[i] = r; if ((i & 1) == 0 && i < 937) z = r; }
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)
28 for (int i = 0; i < 1024; i++)
30 { y = 2 * a[i]; s += y; z = y; }
31 #pragma omp scan inclusive(s)
32 { y = s; b[i] = y + x + 12; }
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) if (simd: 0)
41 for (int i = 0; i < 1024; i++)
43 { r += a[i]; if (i == 1023) x = 29; }
44 #pragma omp scan inclusive(r)
45 b[i] = r;
49 __attribute__((noipa)) int
50 qux (void)
52 int s = 0;
53 #pragma omp parallel for simd simdlen (1) reduction (inscan, +:s) lastprivate (conditional: x, y)
54 for (int i = 0; i < 1024; i++)
56 { s += 2 * a[i]; if ((a[i] & 1) == 1 && i < 825) x = a[i]; }
57 #pragma omp scan inclusive(s)
58 { b[i] = s; if ((a[i] & 1) == 0 && i < 829) y = 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 s += i;
81 if (b[i] != s)
82 abort ();
83 else
84 b[i] = 25;
86 if (bar () != 1024 * 1023 || x != -12 || z != 2 * 1023)
87 abort ();
88 s = 0;
89 for (int i = 0; i < 1024; ++i)
91 s += 2 * i;
92 if (b[i] != s)
93 abort ();
94 else
95 b[i] = -1;
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 s += i;
105 if (b[i] != s)
106 abort ();
107 else
108 b[i] = -25;
110 if (qux () != 1024 * 1023 || x != 823 || y != 828)
111 abort ();
112 s = 0;
113 for (int i = 0; i < 1024; ++i)
115 s += 2 * i;
116 if (b[i] != s)
117 abort ();
119 return 0;