Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / autopar / reduc-1short.c
blob75d09544f8c5696ee2aaf4666a3ebd3a6be5ff6a
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-final_cleanup" } */
4 #include <stdarg.h>
5 #include <stdlib.h>
7 #define N 16
8 #define DIFF 242
10 __attribute__ ((noinline)) void
11 main1 (unsigned short x, unsigned short max_result, unsigned short min_result)
13 int i;
14 unsigned short ub[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
15 unsigned short uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
16 unsigned short udiff = 2;
17 unsigned short umax = x;
18 unsigned short umin = x;
20 for (i = 0; i < N; i++) {
21 udiff += (unsigned short)(ub[i] - uc[i]);
24 for (i = 0; i < N; i++) {
25 umax = umax < uc[i] ? uc[i] : umax;
28 for (i = 0; i < N; i++) {
29 umin = umin > uc[i] ? uc[i] : umin;
32 /* check results: */
33 if (udiff != DIFF)
34 abort ();
35 if (umax != max_result)
36 abort ();
37 if (umin != min_result)
38 abort ();
41 int main (void)
43 main1 (100, 100, 1);
44 main1 (0, 15, 0);
45 return 0;
48 /* { dg-final { scan-tree-dump-times "Detected reduction" 3 "parloops" } } */
49 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 3 "parloops" } } */
50 /* { dg-final { cleanup-tree-dump "parloops" } } */
51 /* { dg-final { cleanup-tree-dump "final_cleanup" } } */