aarch64: Avoid alloca in target attribute parsing
[official-gcc.git] / libgomp / testsuite / libgomp.c / scan-17.c
blob57e4390462a0fafe35cf331d64cfb786335a17fc
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 b[i] = r;
17 #pragma omp scan exclusive(r)
18 r *= a[i];
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 b[i] = s;
30 #pragma omp scan exclusive(s)
31 s = s > a[i] ? s : a[i];
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 if (b[i] != s)
72 abort ();
73 else
74 b[i] = -231.75f;
75 s *= a[i];
76 a[i] = m - ((i % 3) == 1 ? 2.0f : (i % 3) == 2 ? 4.0f : 0.0f);
77 m += 0.75f;
79 if (bar () != 592.0f)
80 abort ();
81 s = -__builtin_inff ();
82 for (int i = 0; i < 1024; ++i)
84 if (b[i] != s)
85 abort ();
86 if (s < a[i])
87 s = a[i];
89 return 0;