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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/* { dg-do assemble } */
/* { dg-options "-O2 -ftree-vectorize -march=armv8-a+sve --save-temps" } */
#ifndef TYPE
#define TYPE unsigned char
#endif
#ifndef NAME
#define NAME(X) X
#endif
#define N 1024
void __attribute__ ((noinline, noclone))
NAME(f2) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c)
{
for (int i = 0; i < N; ++i)
{
a[i] = c[i * 2];
b[i] = c[i * 2 + 1];
}
}
void __attribute__ ((noinline, noclone))
NAME(f3) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
TYPE *__restrict d)
{
for (int i = 0; i < N; ++i)
{
a[i] = d[i * 3];
b[i] = d[i * 3 + 1];
c[i] = d[i * 3 + 2];
}
}
void __attribute__ ((noinline, noclone))
NAME(f4) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
TYPE *__restrict d, TYPE *__restrict e)
{
for (int i = 0; i < N; ++i)
{
a[i] = e[i * 4];
b[i] = e[i * 4 + 1];
c[i] = e[i * 4 + 2];
d[i] = e[i * 4 + 3];
}
}
void __attribute__ ((noinline, noclone))
NAME(g2) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c)
{
for (int i = 0; i < N; ++i)
{
c[i * 2] = a[i];
c[i * 2 + 1] = b[i];
}
}
void __attribute__ ((noinline, noclone))
NAME(g3) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
TYPE *__restrict d)
{
for (int i = 0; i < N; ++i)
{
d[i * 3] = a[i];
d[i * 3 + 1] = b[i];
d[i * 3 + 2] = c[i];
}
}
void __attribute__ ((noinline, noclone))
NAME(g4) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
TYPE *__restrict d, TYPE *__restrict e)
{
for (int i = 0; i < N; ++i)
{
e[i * 4] = a[i];
e[i * 4 + 1] = b[i];
e[i * 4 + 2] = c[i];
e[i * 4 + 3] = d[i];
}
}
/* { dg-final { scan-assembler {\tld2b\t{z[0-9]+.b - z[0-9]+.b}, p[0-7]/z, \[x[0-9]+\]\n} } } */
/* { dg-final { scan-assembler {\tld3b\t{z[0-9]+.b - z[0-9]+.b}, p[0-7]/z, \[x[0-9]+\]\n} } } */
/* { dg-final { scan-assembler {\tld4b\t{z[0-9]+.b - z[0-9]+.b}, p[0-7]/z, \[x[0-9]+\]\n} } } */
/* { dg-final { scan-assembler {\tst2b\t{z[0-9]+.b - z[0-9]+.b}, p[0-7], \[x[0-9]+\]\n} } } */
/* { dg-final { scan-assembler {\tst3b\t{z[0-9]+.b - z[0-9]+.b}, p[0-7], \[x[0-9]+\]\n} } } */
/* { dg-final { scan-assembler {\tst4b\t{z[0-9]+.b - z[0-9]+.b}, p[0-7], \[x[0-9]+\]\n} } } */
|