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 121
9
10 signed char b[N] = {1,2,3,6,8,10,12,14,16,18,20,22,24,26,28,30};
11 signed char c[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
12
13 __attribute__ ((noinline))
main1(signed char x,signed char max_result,signed char min_result)14 void main1 (signed char x, signed char max_result, signed char min_result)
15 {
16 int i;
17 signed char diff = 2;
18 signed char max = x;
19 signed char min = x;
20
21 for (i = 0; i < N; i++) {
22 diff += (signed char)(b[i] - c[i]);
23 }
24
25 for (i = 0; i < N; i++) {
26 max = max < c[i] ? c[i] : max;
27 }
28
29 for (i = 0; i < N; i++) {
30 min = min > c[i] ? c[i] : min;
31 }
32
33 /* check results: */
34 if (diff != DIFF)
35 abort ();
36 if (max != max_result)
37 abort ();
38 if (min != min_result)
39 abort ();
40 }
41
42 void __attribute__((noinline))
43 __attribute__((optimize ("-ftree-parallelize-loops=0")))
init_arrays()44 init_arrays ()
45 {
46 int i;
47
48 for (i=16; i<N; i++)
49 {
50 b[i] = 1;
51 c[i] = 1;
52 }
53 }
54
main(void)55 int main (void)
56 {
57 init_arrays();
58 main1 (100, 100, 1);
59 main1 (0, 15, 0);
60 return 0;
61 }
62
63
64 /* { dg-final { scan-tree-dump-times "Detected reduction" 2 "parloops2" } } */
65 /* { dg-final { scan-tree-dump-times "Detected reduction" 3 "parloops2" { xfail *-*-* } } } */
66
67 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 2 "parloops2" } } */
68 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 3 "parloops2" { xfail *-*-* } } } */
69
70
71