1 /* { dg-do run } */
2 /* { dg-additional-options "-ftree-parallelize-loops=2" } */
3 
4 /* Variable bound, vector addition, unsigned loop counter, unsigned bound.  */
5 
6 #include <stdio.h>
7 #include <stdlib.h>
8 
9 #define N 1000
10 
11 unsigned int a[N];
12 unsigned int b[N];
13 unsigned int c[N];
14 
15 void __attribute__((noclone,noinline))
f(unsigned int n,unsigned int * __restrict__ a,unsigned int * __restrict__ b,unsigned int * __restrict__ c)16 f (unsigned int n, unsigned int *__restrict__ a, unsigned int *__restrict__ b,
17    unsigned int *__restrict__ c)
18 {
19   unsigned int i;
20 
21   for (i = 0; i < n; ++i)
22     c[i] = a[i] + b[i];
23 }
24 
25 static void __attribute__((noclone,noinline))
init(void)26 init (void)
27 {
28   int i, j;
29 
30   /* Complexify loop to inhibit parloops.  */
31   for (j = 0; j < 100; ++j)
32     for (i = 0; i < 10; i++)
33       {
34 	int k = i + (10 * j);
35 	a[k] = k;
36 	b[k] = (k * 3) % 7;
37 	c[k] = k * 2;
38       }
39 }
40 
41 int
main(void)42 main (void)
43 {
44   int i;
45 
46   init ();
47 
48   f (N, a, b, c);
49 
50   for (i = 0; i < N; i++)
51     {
52       unsigned int actual = c[i];
53       unsigned int expected = i + ((i * 3) % 7);
54       if (actual != expected)
55 	abort ();
56     }
57 
58   /* Test low iteration count case.  */
59 
60   init ();
61 
62   f (10, a, b, c);
63 
64   for (i = 0; i < N; i++)
65     {
66       unsigned int actual = c[i];
67       unsigned int expected = (i < 10
68 			       ? i + ((i * 3) % 7)
69 			       : i * 2);
70       if (actual != expected)
71 	abort ();
72     }
73 
74   return 0;
75 }
76