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