OSDN Git Service

* gcc.dg/builtins-config.h: Disable C99 runtime testing for
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / autopar / reduc-2short.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 void main1 (short x, short max_result, short min_result)
12 {
13   int i;
14   short b[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
15   short c[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
16   short diff = 2;
17   short max = x;
18   short min = x;
19
20   for (i = 0; i < N; i++) {
21     diff += (short)(b[i] - c[i]);
22   }
23   for (i = 0; i < N; i++) {
24     max = max < c[i] ? c[i] : max;
25   }
26
27   for (i = 0; i < N; i++) {
28     min = min > c[i] ? c[i] : min;
29   }
30
31   /* check results:  */
32   if (diff != DIFF)
33     abort ();
34   if (max != max_result)
35     abort ();
36   if (min != min_result)
37     abort ();
38 }
39
40 int main (void)
41
42   main1 (100, 100, 1);
43   main1 (0, 15, 0);
44   return 0;
45 }
46
47 /* { dg-final { scan-tree-dump-times "Detected reduction" 2 "parloops" } } */
48 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 2 "parloops" } } */
49 /* { dg-final { cleanup-tree-dump "parloops" } } */
50 /* { dg-final { cleanup-tree-dump "final_cleanup" } } */
51