ada: Fix decoration of iterated component association for GNATprove
[official-gcc.git] / libgomp / testsuite / libgomp.c / scan-13.c
blob9cf1623d2627277a84db5acb02ee969457613b99
1 /* { dg-require-effective-target size32plus } */
2 /* { dg-additional-options "-O2 -fopenmp -fdump-tree-vect-details" } */
3 /* { dg-additional-options "-msse2" { target sse2_runtime } } */
4 /* { dg-additional-options "-mavx" { target avx_runtime } } */
5 /* { dg-final { scan-tree-dump-times "vectorized \[2-6] loops" 2 "vect" { target sse2_runtime } } } */
7 extern void abort (void);
8 float r = 1.0f, a[1024], b[1024];
10 __attribute__((noipa)) void
11 foo (float *a, float *b)
13 #pragma omp for simd reduction (inscan, *:r)
14 for (int i = 0; i < 1024; i++)
16 r *= a[i];
17 #pragma omp scan inclusive(r)
18 b[i] = r;
22 __attribute__((noipa)) float
23 bar (void)
25 float s = -__builtin_inff ();
26 #pragma omp parallel for simd reduction (inscan, max:s)
27 for (int i = 0; i < 1024; i++)
29 s = s > a[i] ? s : a[i];
30 #pragma omp scan inclusive(s)
31 b[i] = s;
33 return s;
36 int
37 main ()
39 float s = 1.0f;
40 for (int i = 0; i < 1024; ++i)
42 if (i < 80)
43 a[i] = (i & 1) ? 0.25f : 0.5f;
44 else if (i < 200)
45 a[i] = (i % 3) == 0 ? 2.0f : (i % 3) == 1 ? 4.0f : 1.0f;
46 else if (i < 280)
47 a[i] = (i & 1) ? 0.25f : 0.5f;
48 else if (i < 380)
49 a[i] = (i % 3) == 0 ? 2.0f : (i % 3) == 1 ? 4.0f : 1.0f;
50 else
51 switch (i % 6)
53 case 0: a[i] = 0.25f; break;
54 case 1: a[i] = 2.0f; break;
55 case 2: a[i] = -1.0f; break;
56 case 3: a[i] = -4.0f; break;
57 case 4: a[i] = 0.5f; break;
58 case 5: a[i] = 1.0f; break;
59 default: a[i] = 0.0f; break;
61 b[i] = -19.0f;
62 asm ("" : "+g" (i));
64 #pragma omp parallel
65 foo (a, b);
66 if (r * 16384.0f != 0.125f)
67 abort ();
68 float m = -175.25f;
69 for (int i = 0; i < 1024; ++i)
71 s *= a[i];
72 if (b[i] != s)
73 abort ();
74 else
76 a[i] = m - ((i % 3) == 1 ? 2.0f : (i % 3) == 2 ? 4.0f : 0.0f);
77 b[i] = -231.75f;
78 m += 0.75f;
81 if (bar () != 592.0f)
82 abort ();
83 s = -__builtin_inff ();
84 for (int i = 0; i < 1024; ++i)
86 if (s < a[i])
87 s = a[i];
88 if (b[i] != s)
89 abort ();
91 return 0;