blob: 3b5875550a0295d93ac7e004191f1a5bb80ba272 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* { dg-do run } */
/* { dg-additional-options "-O2 -fvect-cost-model=cheap -fdump-tree-vect-details" } */
/* { dg-additional-options "-mavx" { target avx_runtime } } */
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" { target avx_runtime } } } */
int v, x;
__attribute__((noipa)) void
foo (int *a)
{
#pragma omp for simd lastprivate (conditional: x) schedule(simd: static)
for (int i = 0; i < 128; i++)
if (a[i])
x = a[i];
}
__attribute__((noipa)) void
bar (int *a, int *b)
{
#pragma omp for simd lastprivate (conditional: x, v) schedule(static, 16)
for (int i = 16; i < 128; ++i)
{
if (a[i])
x = a[i];
if (b[i])
v = b[i] + 10;
}
}
__attribute__((noipa)) void
baz (int *a)
{
#pragma omp for simd lastprivate (conditional: x) schedule(simd: dynamic, 16)
for (int i = 0; i < 128; i++)
if (a[i])
x = a[i] + 5;
}
int
main ()
{
int a[128], b[128], i;
for (i = 0; i < 128; i++)
{
a[i] = ((i % 11) == 2) ? i + 10 : 0;
asm volatile ("" : "+g" (i));
b[i] = ((i % 13) == 5) ? i * 2 : 0;
}
#pragma omp parallel
foo (a);
if (x != 133)
__builtin_abort ();
x = -3;
#pragma omp parallel
bar (b, a);
if (x != 244 || v != 143)
__builtin_abort ();
#pragma omp parallel
baz (b);
if (x != 249)
__builtin_abort ();
return 0;
}
|