Add pass_parallelize_loops to pass_oacc_kernels
[gcc.git] / gcc / testsuite / gcc.dg / autopar / reduc-2.c
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops2-details -fdump-tree-optimized" } */
3
4 #include <stdarg.h>
5 #include <stdlib.h>
6
7 #define N 1600
8 #define DIFF 2558400
9
10 int b[N];
11 int c[N];
12
13 /* Reduction of signed-int. */
14
15 __attribute__ ((noinline))
16 void main1 (int x, int max_result, int min_result)
17 {
18 int i;
19 int diff = 0;
20 int max = x;
21 int min = x;
22
23 for (i = 0; i < N; i++) {
24 diff += (b[i] - c[i]);
25 }
26
27 for (i = 0; i < N; i++) {
28 max = max < c[i] ? c[i] : max;
29 }
30
31 for (i = 0; i < N; i++) {
32 min = min > c[i] ? c[i] : min;
33 }
34
35 /* check results: */
36 if (diff != DIFF)
37 abort ();
38 if (max != max_result)
39 abort ();
40 if (min != min_result)
41 abort ();
42 }
43
44 __attribute__((noinline))
45 void init_arrays ()
46 {
47 int i;
48
49 b[0] = 1;
50 c[0] = 1;
51 for (i=1; i<N; i++)
52 {
53 b[i] = i * 3;
54 c[i] = i;
55 }
56 }
57
58 int main (void)
59 {
60 init_arrays ();
61 main1 (2000, 2000, 1);
62 main1 (0, 1599, 0);
63 return 0;
64 }
65
66 /* { dg-final { scan-tree-dump-times "Detected reduction" 3 "parloops2" { xfail *-*-* } } } */
67 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 4 "parloops2" { xfail *-*-* } } } */
68