Check TYPE_OVERFLOW_WRAPS for parloops reductions
[official-gcc.git] / gcc / testsuite / gcc.dg / autopar / reduc-2.c
blob2f4883d08e45529d4ace18b34730f6c22eb945d3
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
4 #include <stdarg.h>
5 #include <stdlib.h>
7 #define N 1600
8 #define DIFF 2558400
10 int b[N];
11 int c[N];
13 /* Reduction of signed-int. */
15 __attribute__ ((noinline))
16 void main1 (int x, int max_result, int min_result)
18 int i;
19 int diff = 0;
20 int max = x;
21 int min = x;
23 for (i = 0; i < N; i++) {
24 diff += (b[i] - c[i]);
27 for (i = 0; i < N; i++) {
28 max = max < c[i] ? c[i] : max;
31 for (i = 0; i < N; i++) {
32 min = min > c[i] ? c[i] : min;
35 /* check results: */
36 if (diff != DIFF)
37 abort ();
38 if (max != max_result)
39 abort ();
40 if (min != min_result)
41 abort ();
44 __attribute__((noinline))
45 void init_arrays ()
47 int i;
49 b[0] = 1;
50 c[0] = 1;
51 for (i=1; i<N; i++)
53 b[i] = i * 3;
54 c[i] = i;
58 int main (void)
60 init_arrays ();
61 main1 (2000, 2000, 1);
62 main1 (0, 1599, 0);
63 return 0;
66 /* { dg-final { scan-tree-dump-times "Detected reduction" 3 "parloops" { xfail *-*-* } } } */
67 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 4 "parloops" { xfail *-*-* } } } */