2015-06-05 17:57:34 +02:00
|
|
|
/* { dg-do run } */
|
2015-06-15 20:10:51 +02:00
|
|
|
/* { dg-additional-options "-ftree-parallelize-loops=2" } */
|
2015-06-05 17:57:34 +02:00
|
|
|
|
2015-06-13 10:05:44 +02:00
|
|
|
/* Variable bound, reduction. */
|
|
|
|
|
2015-06-23 17:02:25 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2015-06-13 10:05:44 +02:00
|
|
|
#define N 4000
|
|
|
|
|
2015-06-05 17:57:34 +02:00
|
|
|
unsigned int *a;
|
|
|
|
|
|
|
|
unsigned int __attribute__((noclone,noinline))
|
2015-06-30 10:35:57 +02:00
|
|
|
f (unsigned int n, unsigned int *__restrict__ a)
|
2015-06-05 17:57:34 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned int sum = 1;
|
|
|
|
|
|
|
|
for (i = 0; i < n; ++i)
|
|
|
|
sum += a[i];
|
|
|
|
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
unsigned int res;
|
2015-06-13 10:05:44 +02:00
|
|
|
unsigned int array[N];
|
2015-06-05 17:57:34 +02:00
|
|
|
int i;
|
2015-06-23 17:02:25 +02:00
|
|
|
|
2015-06-13 10:05:44 +02:00
|
|
|
for (i = 0; i < N; ++i)
|
2015-06-05 17:57:34 +02:00
|
|
|
array[i] = i % 7;
|
|
|
|
a = &array[0];
|
2015-06-23 17:02:25 +02:00
|
|
|
|
2015-06-30 10:35:57 +02:00
|
|
|
res = f (N, a);
|
2015-06-23 17:02:25 +02:00
|
|
|
if (res != 11995)
|
|
|
|
abort ();
|
|
|
|
|
2015-07-07 18:25:22 +02:00
|
|
|
/* Test low iteration count case. */
|
2015-07-08 14:31:00 +02:00
|
|
|
res = f (10, a);
|
2015-07-07 18:25:22 +02:00
|
|
|
if (res != 25)
|
|
|
|
abort ();
|
|
|
|
|
2015-06-23 17:02:25 +02:00
|
|
|
return 0;
|
2015-06-05 17:57:34 +02:00
|
|
|
}
|