1 /* { dg-do run } */
2 
3 extern void abort (void);
4 
5 unsigned long long int x, i, j;
6 volatile unsigned long long int a, b, c, d, e, f, g, h;
7 int k[4][206];
8 
9 int
main()10 main ()
11 {
12   long long int niters;
13   for (j = ~0ULL / 2 - 32; j < ((~0ULL / 2) + 6); j++)
14     k[0][j - ~0ULL / 2 + 64] = 1;
15   a = 1; b = 2; c = 1; d = 0; e = ~0ULL / 2 - 32; f = ((~0ULL / 2) + 6); g = 0; h = 1;
16   niters = 0; i = -100; j = -100; x = -100;
17   #pragma omp parallel for collapse(2) lastprivate (i, j, x) reduction(+:niters)
18   for (i = 1; i < 2; i++)
19     for (j = ~0ULL / 2 - 32; j < i * ((~0ULL / 2) + 6); j++)
20       {
21 	if (i != 1 || j < ~0ULL / 2 - 32 || j >= ((~0ULL / 2) + 6) || k[0][j - ~0ULL / 2 + 64] != 1)
22 	  abort ();
23 	k[0][j - ~0ULL / 2 + 64]++;
24 	x = i * 1024 + (j & 1023);
25 	niters++;
26       }
27   if (i != 2 || j != ((~0ULL / 2) + 6) || x != 1028 || niters != 38)
28     abort ();
29   niters = 0; i = -100; j = -100; x = -100;
30   #pragma omp parallel for collapse(2) lastprivate (i, j, x) reduction(+:niters)
31   for (i = a; i < b; i += c)
32     for (j = d * i + e; j < g + i * f; j += h)
33       {
34 	if (i != 1 || j < ~0ULL / 2 - 32 || j >= ((~0ULL / 2) + 6) || k[0][j - ~0ULL / 2 + 64] != 2)
35 	  abort ();
36 	k[0][j - ~0ULL / 2 + 64]++;
37 	x = i * 1024 + (j & 1023);
38 	niters++;
39       }
40   if (i != 2 || j != ((~0ULL / 2) + 6) || x != 1028 || niters != 38)
41     abort ();
42   for (j = ~0ULL / 2 - 32; j < ((~0ULL / 2) + 6); j++)
43     if (k[0][j - ~0ULL / 2 + 64] == 3)
44       k[0][j - ~0ULL / 2 + 64] = 0;
45     else
46       abort ();
47   for (i = 1; i < 4; i++)
48     for (j = 64ULL * i; j < i * 32ULL + 110; j++)
49       k[i][j] = 1;
50   a = 1; b = 4; c = 1; d = 64ULL; e = 0; f = 32ULL; g = 110ULL; h = 1;
51   niters = 0; i = -100; j = -100; x = -100;
52   #pragma omp parallel for collapse(2) lastprivate (i, j, x) reduction(+:niters)
53   for (i = 1; i < 4; i++)
54     for (j = 64ULL * i; j < i * 32ULL + 110; j++)
55       {
56 	if (i < 1 || i >= 4 || j < 64ULL * i || j >= i * 32ULL + 110 || k[i][j] != 1)
57 	  abort ();
58 	k[i][j]++;
59 	x = i * 1024 + (j & 1023);
60 	niters++;
61       }
62   if (i != 4 || j != 206 || x != 3277 || niters != 138)
63     abort ();
64   niters = 0; i = -100; j = -100; x = -100;
65   #pragma omp parallel for collapse(2) lastprivate (i, j, x) reduction(+:niters)
66   for (i = a; i < b; i += c)
67     for (j = d * i + e; j < g + i * f; j += h)
68       {
69 	if (i < 1 || i >= 4 || j < 64ULL * i || j >= i * 32ULL + 110 || k[i][j] != 2)
70 	  abort ();
71 	k[i][j]++;
72 	x = i * 1024 + (j & 1023);
73 	niters++;
74       }
75   if (i != 4 || j != 206 || x != 3277 || niters != 138)
76     abort ();
77   for (i = 1; i < 4; i++)
78     for (j = 64ULL * i; j < i * 32ULL + 110; j++)
79       if (k[i][j] == 3)
80 	k[i][j] = 0;
81       else
82 	abort ();
83   return 0;
84 }
85