sched1: debug/model: dump predecessor list and BB num [NFC]
[gcc.git] / libgomp / testsuite / libgomp.c / scan-16.c
blob8b816781dd8e9caf0e36a900f564e5e6a365264b
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];
10 #pragma omp declare reduction (foo: int: omp_out += omp_in) initializer (omp_priv = 0)
12 __attribute__((noipa)) void
13 foo (int *a, int *b)
15 #pragma omp for simd reduction (inscan, foo:r)
16 for (int i = 0; i < 1024; i++)
18 b[i] = r;
19 #pragma omp scan exclusive(r)
20 r += a[i];
24 __attribute__((noipa)) int
25 bar (void)
27 int s = 0;
28 #pragma omp parallel
29 #pragma omp for simd simdlen (1) reduction (inscan, foo:s)
30 for (int i = 0; i < 1024; i++)
32 b[i] = s;
33 #pragma omp scan exclusive(s)
34 s += 2 * a[i];
36 return s;
39 __attribute__((noipa)) void
40 baz (int *a, int *b)
42 #pragma omp parallel for simd if (simd: 0) reduction (inscan, foo:r)
43 for (int i = 0; i < 1024; i++)
45 b[i] = r;
46 #pragma omp scan exclusive(r)
47 r += a[i];
51 __attribute__((noipa)) int
52 qux (void)
54 int s = 0;
55 #pragma omp parallel for simd reduction (inscan, foo:s)
56 for (int i = 0; i < 1024; i++)
58 b[i] = s;
59 #pragma omp scan exclusive(s)
60 s += 2 * a[i];
62 return s;
65 int
66 main ()
68 int s = 0;
69 for (int i = 0; i < 1024; ++i)
71 a[i] = i;
72 b[i] = -1;
73 asm ("" : "+g" (i));
75 #pragma omp parallel
76 foo (a, b);
77 if (r != 1024 * 1023 / 2)
78 abort ();
79 for (int i = 0; i < 1024; ++i)
81 if (b[i] != s)
82 abort ();
83 else
84 b[i] = 25;
85 s += i;
87 if (bar () != 1024 * 1023)
88 abort ();
89 s = 0;
90 for (int i = 0; i < 1024; ++i)
92 if (b[i] != s)
93 abort ();
94 else
95 b[i] = -1;
96 s += 2 * i;
98 r = 0;
99 baz (a, b);
100 if (r != 1024 * 1023 / 2)
101 abort ();
102 s = 0;
103 for (int i = 0; i < 1024; ++i)
105 if (b[i] != s)
106 abort ();
107 else
108 b[i] = -25;
109 s += i;
111 if (qux () != 1024 * 1023)
112 abort ();
113 s = 0;
114 for (int i = 0; i < 1024; ++i)
116 if (b[i] != s)
117 abort ();
118 s += 2 * i;
120 return 0;