* gcc.dg/predict-12.c: New testcase.
[official-gcc.git] / gcc / testsuite / gcc.dg / autopar / reduc-1.c
blob1e5f923376fea7237f92768eb11b5d35a5c2e921
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops2-details -fdump-tree-optimized" } */
4 #include <stdarg.h>
5 #include <stdlib.h>
7 #define N 1600
8 #define DIFF 2558402
10 unsigned int ub[N];
11 unsigned int uc[N];
13 /* Reduction of unsigned-int. */
15 void main1 (unsigned int x, unsigned int max_result, unsigned int min_result)
17 int i;
18 unsigned int udiff = 2;
19 unsigned int umax = x;
20 unsigned int umin = x;
22 /* Summation. */
23 for (i = 0; i < N; i++) {
24 udiff += (ub[i] - uc[i]);
27 /* Maximum. */
28 for (i = 0; i < N; i++) {
29 umax = umax < uc[i] ? uc[i] : umax;
32 /* Minimum. */
33 for (i = 0; i < N; i++) {
34 umin = umin > uc[i] ? uc[i] : umin;
37 /* check results: */
38 if (udiff != DIFF)
39 abort ();
40 if (umax != max_result)
41 abort ();
42 if (umin != min_result)
43 abort ();
46 __attribute__((noinline))
47 void init_arrays ()
49 int i;
51 ub[0] = 1;
52 uc[0] = 1;
53 for (i=1; i<N; i++)
55 ub[i] = i * 3;
56 uc[i] = i;
60 int main (void)
62 init_arrays ();
63 main1 (2000, 2000, 1);
64 main1 (0, 1599, 0);
65 return 0;
69 /* { dg-final { scan-tree-dump-times "Detected reduction" 3 "parloops2" } } */
70 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 4 "parloops2" } } */