sched1: debug/model: dump predecessor list and BB num [NFC]
[gcc.git] / libgomp / testsuite / libgomp.c / scan-15.c
blobc0c6dfd3b99c473bf373743ae80da2f3f1405a6b
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 __attribute__((noipa)) void
11 foo (int *a, int *b)
13 #pragma omp for simd reduction (inscan, +:r)
14 for (int i = 0; i < 1024; i++)
16 b[i] = r;
17 #pragma omp scan exclusive(r)
18 r += a[i];
22 __attribute__((noipa)) int
23 bar (void)
25 int s = 0;
26 #pragma omp parallel
27 #pragma omp for simd reduction (inscan, +:s)
28 for (int i = 0; i < 1024; i++)
30 b[i] = s;
31 #pragma omp scan exclusive(s)
32 s += 2 * a[i];
34 return s;
37 __attribute__((noipa)) void
38 baz (int *a, int *b)
40 #pragma omp parallel for simd simdlen (1) reduction (inscan, +:r)
41 for (int i = 0; i < 1024; i++)
43 b[i] = r;
44 #pragma omp scan exclusive(r)
45 r += a[i];
49 __attribute__((noipa)) int
50 qux (void)
52 int s = 0;
53 #pragma omp parallel for simd if (simd: 0) reduction (inscan, +:s)
54 for (int i = 0; i < 1024; i++)
56 b[i] = s;
57 #pragma omp scan exclusive(s)
58 s += 2 * a[i];
60 return s;
63 int
64 main ()
66 int s = 0;
67 for (int i = 0; i < 1024; ++i)
69 a[i] = i;
70 b[i] = -1;
71 asm ("" : "+g" (i));
73 #pragma omp parallel
74 foo (a, b);
75 if (r != 1024 * 1023 / 2)
76 abort ();
77 for (int i = 0; i < 1024; ++i)
79 if (b[i] != s)
80 abort ();
81 else
82 b[i] = 25;
83 s += i;
85 if (bar () != 1024 * 1023)
86 abort ();
87 s = 0;
88 for (int i = 0; i < 1024; ++i)
90 if (b[i] != s)
91 abort ();
92 else
93 b[i] = -1;
94 s += 2 * i;
96 r = 0;
97 baz (a, b);
98 if (r != 1024 * 1023 / 2)
99 abort ();
100 s = 0;
101 for (int i = 0; i < 1024; ++i)
103 if (b[i] != s)
104 abort ();
105 else
106 b[i] = -25;
107 s += i;
109 if (qux () != 1024 * 1023)
110 abort ();
111 s = 0;
112 for (int i = 0; i < 1024; ++i)
114 if (b[i] != s)
115 abort ();
116 s += 2 * i;
118 return 0;