Fix xfail for 32-bit hppa*-*-* in gcc.dg/pr84877.c
[official-gcc.git] / libgomp / testsuite / libgomp.c++ / attrs-imperfect6.C
blob01f9be123a65dc7881153313b6cc0bf368f0f594
1 /* { dg-do run } */
3 /* Like imperfect4.c, but bind the iteration variables in the loops.  */
5 static int f1count[3], f2count[3];
6 static int g1count[3], g2count[3];
8 #ifndef __cplusplus
9 extern void abort (void);
10 #else
11 extern "C" void abort (void);
12 #endif
14 int f1 (int depth, int iter)
16   f1count[depth]++;
17   return iter;
20 int f2 (int depth, int iter)
22   f2count[depth]++;
23   return iter;
26 int g1 (int depth, int iter)
28   g1count[depth]++;
29   return iter;
32 int g2 (int depth, int iter)
34   g2count[depth]++;
35   return iter;
38 void s1 (int a1, int a2, int a3)
41   [[ omp :: directive (for, collapse(3)) ]]
42   for (int i = 0; i < a1; i++)
43     {
44       { f1 (0, i); }
45       {
46         g1 (0, i);
47         for (int j = 0; j < a2; j++)
48           {
49             { f1 (1, j); }
50             {
51               { g1 (1, j); }
52               for (int k = 0; k < a3; k++)
53                 {
54                   f1 (2, k);
55                   {
56                     g1 (2, k);
57                     g2 (2, k);
58                   }
59                   f2 (2, k);
60                 }
61               { g2 (1, j); }
62             }
63             { f2 (1, j); }
64           }
65         { g2 (0, i); }
66       }
67       { f2 (0, i); }
68     }
71 int
72 main (void)
74   f1count[0] = 0;
75   f1count[1] = 0;
76   f1count[2] = 0;
77   f2count[0] = 0;
78   f2count[1] = 0;
79   f2count[2] = 0;
81   g1count[0] = 0;
82   g1count[1] = 0;
83   g1count[2] = 0;
84   g2count[0] = 0;
85   g2count[1] = 0;
86   g2count[2] = 0;
88   s1 (3, 4, 5);
90   /* All intervening code at the same depth must be executed the same
91      number of times. */
92   if (f1count[0] != f2count[0]) abort ();
93   if (f1count[1] != f2count[1]) abort ();
94   if (f1count[2] != f2count[2]) abort ();
95   if (g1count[0] != f1count[0]) abort ();
96   if (g2count[0] != f1count[0]) abort ();
97   if (g1count[1] != f1count[1]) abort ();
98   if (g2count[1] != f1count[1]) abort ();
99   if (g1count[2] != f1count[2]) abort ();
100   if (g2count[2] != f1count[2]) abort ();
102   /* Intervening code must be executed at least as many times as the loop
103      that encloses it. */
104   if (f1count[0] < 3) abort ();
105   if (f1count[1] < 3 * 4) abort ();
107   /* Intervening code must not be executed more times than the number
108      of logical iterations. */
109   if (f1count[0] > 3 * 4 * 5) abort ();
110   if (f1count[1] > 3 * 4 * 5) abort ();
112   /* Check that the innermost loop body is executed exactly the number
113      of logical iterations expected. */
114   if (f1count[2] != 3 * 4 * 5) abort ();