1  /* { dg-do run } */
       2  /* { dg-additional-options "-ftree-parallelize-loops=2" } */
       3  
       4  /* Variable bound, reduction.  */
       5  
       6  #include <stdlib.h>
       7  
       8  #define N 4000
       9  
      10  unsigned int *a;
      11  
      12  unsigned int __attribute__((noclone,noinline))
      13  f (unsigned int n, unsigned int *__restrict__ a)
      14  {
      15    int i;
      16    unsigned int sum = 1;
      17  
      18    for (i = 0; i < n; ++i)
      19      sum += a[i];
      20  
      21    return sum;
      22  }
      23  
      24  int
      25  main (void)
      26  {
      27    unsigned int res;
      28    unsigned int array[N];
      29    int i;
      30  
      31    for (i = 0; i < N; ++i)
      32      array[i] = i % 7;
      33    a = &array[0];
      34  
      35    res = f (N, a);
      36    if (res != 11995)
      37      abort ();
      38  
      39    /* Test low iteration count case.  */
      40    res = f (10, a);
      41    if (res != 25)
      42      abort ();
      43  
      44    return 0;
      45  }