Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / autopar / reduc-6.c
blob22a2e6255f46224a8532272186b2365a167aa443
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
11 __attribute__ ((noinline))
12 int main1 (float x, float max_result)
14 int i;
15 float b[N];
16 float c[N];
17 float diff = 2;
18 float max = x;
19 float min = 10;
21 for (i=0; i<N; i++)
23 b[i] = i * 3;
24 c[i] = i;
27 for (i = 0; i < N; i++) {
28 diff += (b[i] - c[i]);
31 for (i = 0; i < N; i++) {
32 max = max < c[i] ? c[i] : max;
35 for (i = 0; i < N; i++) {
36 min = min > c[i] ? c[i] : min;
39 /* check results: */
40 if (diff != DIFF)
41 abort ();
42 if (max != max_result)
43 abort ();
44 if (min != 0)
45 abort ();
47 return 0;
50 int main (void)
52 main1 (2000, 2000);
53 main1 (0, 1599);
54 return 0;
58 /* need -ffast-math to parallelize these loops. */
59 /* { dg-final { scan-tree-dump-times "Detected reduction" 0 "parloops2" } } */
60 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops2" } } */
61 /* { dg-final { scan-tree-dump-times "FAILED: it is not a part of reduction" 3 "parloops2" } } */