Fix xfail for 32-bit hppa*-*-* in gcc.dg/pr84877.c
[official-gcc.git] / libgomp / testsuite / libgomp.c++ / scan-1.C
blobd148dac924b37fbcf1ca56eafd996eb4064283c9
1 // { dg-require-effective-target size32plus }
3 extern "C" void abort ();
5 struct S {
6   inline S ();
7   inline ~S ();
8   inline S (const S &);
9   inline S & operator= (const S &);
10   int s;
13 S::S () : s (0)
17 S::~S ()
21 S::S (const S &x)
23   s = x.s;
26 S &
27 S::operator= (const S &x)
29   s = x.s;
30   return *this;
33 static inline void
34 ini (S &x)
36   x.s = 0;
39 S r, a[1024], b[1024];
41 #pragma omp declare reduction (+: S: omp_out.s += omp_in.s)
42 #pragma omp declare reduction (plus: S: omp_out.s += omp_in.s) initializer (ini (omp_priv))
44 __attribute__((noipa)) void
45 foo (S *a, S *b)
47   #pragma omp for reduction (inscan, +:r)
48   for (int i = 0; i < 1024; i++)
49     {
50       r.s += a[i].s;
51       #pragma omp scan inclusive(r)
52       b[i] = r;
53     }
56 __attribute__((noipa)) S
57 bar (void)
59   S s;
60   #pragma omp parallel
61   #pragma omp for reduction (inscan, plus:s)
62   for (int i = 0; i < 1024; i++)
63     {
64       s.s += 2 * a[i].s;
65       #pragma omp scan inclusive(s)
66       b[i] = s;
67     }
68   return S (s);
71 __attribute__((noipa)) void
72 baz (S *a, S *b)
74   #pragma omp parallel for reduction (inscan, +:r)
75   for (int i = 0; i < 1024; i++)
76     {
77       r.s += a[i].s;
78       #pragma omp scan inclusive(r)
79       b[i] = r;
80     }
83 __attribute__((noipa)) S
84 qux (void)
86   S s;
87   #pragma omp parallel for reduction (inscan, plus:s)
88   for (int i = 0; i < 1024; i++)
89     {
90       s.s += 2 * a[i].s;
91       #pragma omp scan inclusive(s)
92       b[i] = s;
93     }
94   return S (s);
97 int
98 main ()
100   S s;
101   for (int i = 0; i < 1024; ++i)
102     {
103       a[i].s = i;
104       b[i].s = -1;
105       asm ("" : "+g" (i));
106     }
107   #pragma omp parallel
108   foo (a, b);
109   if (r.s != 1024 * 1023 / 2)
110     abort ();
111   for (int i = 0; i < 1024; ++i)
112     {
113       s.s += i;
114       if (b[i].s != s.s)
115         abort ();
116       else
117         b[i].s = 25;
118     }
119   if (bar ().s != 1024 * 1023)
120     abort ();
121   s.s = 0;
122   for (int i = 0; i < 1024; ++i)
123     {
124       s.s += 2 * i;
125       if (b[i].s != s.s)
126         abort ();
127     }
128   r.s = 0;
129   baz (a, b);
130   if (r.s != 1024 * 1023 / 2)
131     abort ();
132   s.s = 0;
133   for (int i = 0; i < 1024; ++i)
134     {
135       s.s += i;
136       if (b[i].s != s.s)
137         abort ();
138       else
139         b[i].s = 25;
140     }
141   if (qux ().s != 1024 * 1023)
142     abort ();
143   s.s = 0;
144   for (int i = 0; i < 1024; ++i)
145     {
146       s.s += 2 * i;
147       if (b[i].s != s.s)
148         abort ();
149     }
150   return 0;