Fix type compatibility for types with flexible array member 2/2 [PR113688,PR114713...
[gcc.git] / libgomp / testsuite / libgomp.c / parloops-exit-first-loop-alt-5.c
blobd8d49b41aa5d59b01244bfe3d9e2aae50cd4b64b
1 /* { dg-do run } */
2 /* { dg-additional-options "-ftree-parallelize-loops=2" } */
4 /* Variable bound, vector addition, unsigned loop counter, unsigned bound. */
6 #include <stdio.h>
7 #include <stdlib.h>
9 #define N 1000
11 unsigned int a[N];
12 unsigned int b[N];
13 unsigned int c[N];
15 void __attribute__((noclone,noinline))
16 f (unsigned int n, unsigned int *__restrict__ a, unsigned int *__restrict__ b,
17 unsigned int *__restrict__ c)
19 unsigned int i;
21 for (i = 0; i < n; ++i)
22 c[i] = a[i] + b[i];
25 static void __attribute__((noclone,noinline))
26 init (void)
28 int i, j;
30 /* Complexify loop to inhibit parloops. */
31 for (j = 0; j < 100; ++j)
32 for (i = 0; i < 10; i++)
34 int k = i + (10 * j);
35 a[k] = k;
36 b[k] = (k * 3) % 7;
37 c[k] = k * 2;
41 int
42 main (void)
44 int i;
46 init ();
48 f (N, a, b, c);
50 for (i = 0; i < N; i++)
52 unsigned int actual = c[i];
53 unsigned int expected = i + ((i * 3) % 7);
54 if (actual != expected)
55 abort ();
58 /* Test low iteration count case. */
60 init ();
62 f (10, a, b, c);
64 for (i = 0; i < N; i++)
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 ();
74 return 0;