OSDN Git Service

2008-01-17 Sebastian Pop <sebastian.pop@amd.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / autopar / reduc-6.c
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-final_cleanup" } */
3
4 #include <stdarg.h>
5 #include <stdlib.h>
6
7 #define N 16
8 #define DIFF 242
9
10 __attribute__ ((noinline))
11 int main1 (float x, float max_result)
12 {
13   int i;
14   float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
15   float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
16   float diff = 2;
17   float max = x;
18   float min = 10;
19
20   for (i = 0; i < N; i++) {
21     diff += (b[i] - c[i]);
22   }
23
24   for (i = 0; i < N; i++) {
25     max = max < c[i] ? c[i] : max;
26   }
27
28   for (i = 0; i < N; i++) {
29     min = min > c[i] ? c[i] : min;
30   }
31
32   /* check results:  */
33   if (diff != DIFF)
34     abort ();
35   if (max != max_result)
36     abort ();
37   if (min != 0)
38     abort ();
39
40   return 0;
41 }
42
43 int main (void)
44
45   main1 (100 ,100);
46   main1 (0, 15);
47   return 0;
48 }
49
50 /* need -ffast-math to  parallelize these loops.  */
51 /* { dg-final { scan-tree-dump-times "Detected reduction" 0 "parloops" } } */
52 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 0 "parloops" } } */
53 /* { dg-final { scan-tree-dump-times "FAILED: it is not a part of reduction" 3 "parloops" } } */
54 /* { dg-final { cleanup-tree-dump "parloops" } } */
55 /* { dg-final { cleanup-tree-dump "final_cleanup" } } */