1 // { dg-do run }
2
3 char z[10] = { 0 };
4
5 __attribute__((noinline, noclone)) void
foo(int (* & x)[3][2],int * y,long (& w)[1][2],int s,int t)6 foo (int (*&x)[3][2], int *y, long (&w)[1][2], int s, int t)
7 {
8 unsigned long long a[9] = {};
9 short b[5] = {};
10 #pragma omp parallel for reduction(+:x[-1:2][:][0:2], z[t + 2:4]) \
11 reduction(*:y[-s:3]) reduction(|:a[s + 3:4]) \
12 reduction(&:w[s + 1:][t:2]) reduction(max:b[2:])
13 for (int i = 0; i < 128; i++)
14 {
15 x[i / 64 - 1][i % 3][(i / 4) & 1] += i;
16 if ((i & 15) == 1)
17 y[1] *= 3;
18 if ((i & 31) == 2)
19 y[2] *= 7;
20 if ((i & 63) == 3)
21 y[3] *= 17;
22 z[i / 32 + 2] += (i & 3);
23 if (i < 4)
24 z[i + 2] += i;
25 a[i / 32 + 2] |= 1ULL << (i & 30);
26 w[0][i & 1] &= ~(1L << (i / 17 * 3));
27 if ((i % 23) > b[2])
28 b[2] = i % 23;
29 if ((i % 85) > b[3])
30 b[3] = i % 85;
31 if ((i % 192) > b[4])
32 b[4] = i % 192;
33 }
34 for (int i = 0; i < 9; i++)
35 if (a[i] != ((i < 6 && i >= 2) ? 0x55555555ULL : 0))
36 __builtin_abort ();
37 if (b[0] != 0 || b[1] != 0 || b[2] != 22 || b[3] != 84 || b[4] != 127)
38 __builtin_abort ();
39 }
40
41 int a3[4][3][2];
42 int (*p3)[3][2] = &a3[2];
43 int y3[5] = { 0, 1, 1, 1, 0 };
44 long w3[1][2] = { ~0L, ~0L };
45 short bb[5];
46
47 struct S
48 {
49 int (*&x)[3][2];
50 int *y;
51 long (&w)[1][2];
52 char z[10];
53 short (&b)[5];
54 unsigned long long a[9];
SS55 S() : x(p3), y(y3), w(w3), z(), a(), b(bb) {}
56 __attribute__((noinline, noclone)) void foo (int s, int t);
57 };
58
59 void
foo(int s,int t)60 S::foo (int s, int t)
61 {
62 #pragma omp parallel for reduction(+:x[-1:2][:][0:2], z[t + 2:4]) \
63 reduction(*:y[-s:3]) reduction(|:a[s + 3:4]) \
64 reduction(&:w[s + 1:][t:2]) reduction(max:b[2:])
65 for (int i = 0; i < 128; i++)
66 {
67 x[i / 64 - 1][i % 3][(i / 4) & 1] += i;
68 if ((i & 15) == 1)
69 y[1] *= 3;
70 if ((i & 31) == 2)
71 y[2] *= 7;
72 if ((i & 63) == 3)
73 y[3] *= 17;
74 z[i / 32 + 2] += (i & 3);
75 if (i < 4)
76 z[i + 2] += i;
77 a[i / 32 + 2] |= 1ULL << (i & 30);
78 w[0][i & 1] &= ~(1L << (i / 17 * 3));
79 if ((i % 23) > b[2])
80 b[2] = i % 23;
81 if ((i % 85) > b[3])
82 b[3] = i % 85;
83 if ((i % 192) > b[4])
84 b[4] = i % 192;
85 }
86 }
87
88 int
main()89 main ()
90 {
91 int a[4][3][2] = {};
92 static int a2[4][3][2] = {{{ 0, 0 }, { 0, 0 }, { 0, 0 }},
93 {{ 312, 381 }, { 295, 356 }, { 337, 335 }},
94 {{ 1041, 975 }, { 1016, 1085 }, { 935, 1060 }},
95 {{ 0, 0 }, { 0, 0 }, { 0, 0 }}};
96 int (*p)[3][2] = &a[2];
97 int y[5] = { 0, 1, 1, 1, 0 };
98 int y2[5] = { 0, 6561, 2401, 289, 0 };
99 char z2[10] = { 0, 0, 48, 49, 50, 51, 0, 0, 0, 0 };
100 long w[1][2] = { ~0L, ~0L };
101 foo (p, y, w, -1, 0);
102 if (__builtin_memcmp (a, a2, sizeof (a))
103 || __builtin_memcmp (y, y2, sizeof (y))
104 || __builtin_memcmp (z, z2, sizeof (z))
105 || w[0][0] != ~0x249249L
106 || w[0][1] != ~0x249249L)
107 __builtin_abort ();
108 S s;
109 s.foo (-1, 0);
110 for (int i = 0; i < 9; i++)
111 if (s.a[i] != ((i < 6 && i >= 2) ? 0x55555555ULL : 0))
112 __builtin_abort ();
113 if (__builtin_memcmp (a3, a2, sizeof (a3))
114 || __builtin_memcmp (y3, y2, sizeof (y3))
115 || __builtin_memcmp (s.z, z2, sizeof (s.z))
116 || w3[0][0] != ~0x249249L
117 || w3[0][1] != ~0x249249L)
118 __builtin_abort ();
119 if (bb[0] != 0 || bb[1] != 0 || bb[2] != 22 || bb[3] != 84 || bb[4] != 127)
120 __builtin_abort ();
121 }
122