Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/autovec/struct/struct_vect-1.c

raw
1 /* { dg-do compile } */
2 /* { dg-additional-options "-std=c99 -march=rv32gcv_zvfh -mabi=ilp32d -mrvv-vector-bits=zvl -funroll-all-loops -fno-schedule-insns -fno-schedule-insns2" } */
3
4 #include <stdint-gcc.h>
5 #ifndef TYPE
6 #define TYPE uint8_t
7 #endif
8
9 #ifndef NAME
10 #define NAME(X) X
11 #endif
12
13 #ifndef N
14 #define N 1024
15 #endif
16
17 void __attribute__ ((noinline, noclone))
18 NAME(f2) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c)
19 {
20 for (int i = 0; i < N; ++i)
21 {
22 a[i] = c[i * 2];
23 b[i] = c[i * 2 + 1];
24 }
25 }
26
27 void __attribute__ ((noinline, noclone))
28 NAME(f3) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
29 TYPE *__restrict d)
30 {
31 for (int i = 0; i < N; ++i)
32 {
33 a[i] = d[i * 3];
34 b[i] = d[i * 3 + 1];
35 c[i] = d[i * 3 + 2];
36 }
37 }
38
39 void __attribute__ ((noinline, noclone))
40 NAME(f4) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
41 TYPE *__restrict d, TYPE *__restrict e)
42 {
43 for (int i = 0; i < N; ++i)
44 {
45 a[i] = e[i * 4];
46 b[i] = e[i * 4 + 1];
47 c[i] = e[i * 4 + 2];
48 d[i] = e[i * 4 + 3];
49 }
50 }
51
52 void __attribute__ ((noinline, noclone))
53 NAME(f5) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
54 TYPE *__restrict d, TYPE *__restrict e, TYPE *__restrict f)
55 {
56 for (int i = 0; i < N; ++i)
57 {
58 a[i] = f[i * 5];
59 b[i] = f[i * 5 + 1];
60 c[i] = f[i * 5 + 2];
61 d[i] = f[i * 5 + 3];
62 e[i] = f[i * 5 + 4];
63 }
64 }
65
66 void __attribute__ ((noinline, noclone))
67 NAME(f6) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
68 TYPE *__restrict d, TYPE *__restrict e, TYPE *__restrict f,
69 TYPE *__restrict g)
70 {
71 for (int i = 0; i < N; ++i)
72 {
73 a[i] = g[i * 6];
74 b[i] = g[i * 6 + 1];
75 c[i] = g[i * 6 + 2];
76 d[i] = g[i * 6 + 3];
77 e[i] = g[i * 6 + 4];
78 f[i] = g[i * 6 + 5];
79 }
80 }
81
82 void __attribute__ ((noinline, noclone))
83 NAME(f7) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
84 TYPE *__restrict d, TYPE *__restrict e, TYPE *__restrict f,
85 TYPE *__restrict g, TYPE *__restrict h)
86 {
87 for (int i = 0; i < N; ++i)
88 {
89 a[i] = h[i * 7];
90 b[i] = h[i * 7 + 1];
91 c[i] = h[i * 7 + 2];
92 d[i] = h[i * 7 + 3];
93 e[i] = h[i * 7 + 4];
94 f[i] = h[i * 7 + 5];
95 g[i] = h[i * 7 + 6];
96 }
97 }
98
99 void __attribute__ ((noinline, noclone))
100 NAME(f8) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
101 TYPE *__restrict d, TYPE *__restrict e, TYPE *__restrict f,
102 TYPE *__restrict g, TYPE *__restrict h, TYPE *__restrict j)
103 {
104 for (int i = 0; i < N; ++i)
105 {
106 a[i] = j[i * 8];
107 b[i] = j[i * 8 + 1];
108 c[i] = j[i * 8 + 2];
109 d[i] = j[i * 8 + 3];
110 e[i] = j[i * 8 + 4];
111 f[i] = j[i * 8 + 5];
112 g[i] = j[i * 8 + 6];
113 h[i] = j[i * 8 + 7];
114 }
115 }
116
117 void __attribute__ ((noinline, noclone))
118 NAME(g2) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c)
119 {
120 for (int i = 0; i < N; ++i)
121 {
122 c[i * 2] = a[i];
123 c[i * 2 + 1] = b[i];
124 }
125 }
126
127 void __attribute__ ((noinline, noclone))
128 NAME(g3) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
129 TYPE *__restrict d)
130 {
131 for (int i = 0; i < N; ++i)
132 {
133 d[i * 3] = a[i];
134 d[i * 3 + 1] = b[i];
135 d[i * 3 + 2] = c[i];
136 }
137 }
138
139 void __attribute__ ((noinline, noclone))
140 NAME(g4) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
141 TYPE *__restrict d, TYPE *__restrict e)
142 {
143 for (int i = 0; i < N; ++i)
144 {
145 e[i * 4] = a[i];
146 e[i * 4 + 1] = b[i];
147 e[i * 4 + 2] = c[i];
148 e[i * 4 + 3] = d[i];
149 }
150 }
151
152 void __attribute__ ((noinline, noclone))
153 NAME(g5) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
154 TYPE *__restrict d, TYPE *__restrict e, TYPE *__restrict f)
155 {
156 for (int i = 0; i < N; ++i)
157 {
158 f[i * 5] = a[i];
159 f[i * 5 + 1] = b[i];
160 f[i * 5 + 2] = c[i];
161 f[i * 5 + 3] = d[i];
162 f[i * 5 + 4] = e[i];
163 }
164 }
165
166 void __attribute__ ((noinline, noclone))
167 NAME(g6) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
168 TYPE *__restrict d, TYPE *__restrict e, TYPE *__restrict f,
169 TYPE *__restrict g)
170 {
171 for (int i = 0; i < N; ++i)
172 {
173 g[i * 6] = a[i];
174 g[i * 6 + 1] = b[i];
175 g[i * 6 + 2] = c[i];
176 g[i * 6 + 3] = d[i];
177 g[i * 6 + 4] = e[i];
178 g[i * 6 + 5] = f[i];
179 }
180 }
181
182 void __attribute__ ((noinline, noclone))
183 NAME(g7) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
184 TYPE *__restrict d, TYPE *__restrict e, TYPE *__restrict f,
185 TYPE *__restrict g, TYPE *__restrict h)
186 {
187 for (int i = 0; i < N; ++i)
188 {
189 h[i * 7] = a[i];
190 h[i * 7 + 1] = b[i];
191 h[i * 7 + 2] = c[i];
192 h[i * 7 + 3] = d[i];
193 h[i * 7 + 4] = e[i];
194 h[i * 7 + 5] = f[i];
195 h[i * 7 + 6] = g[i];
196 }
197 }
198
199 void __attribute__ ((noinline, noclone))
200 NAME(g8) (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c,
201 TYPE *__restrict d, TYPE *__restrict e, TYPE *__restrict f,
202 TYPE *__restrict g, TYPE *__restrict h, TYPE *__restrict j)
203 {
204 for (int i = 0; i < N; ++i)
205 {
206 j[i * 8] = a[i];
207 j[i * 8 + 1] = b[i];
208 j[i * 8 + 2] = c[i];
209 j[i * 8 + 3] = d[i];
210 j[i * 8 + 4] = e[i];
211 j[i * 8 + 5] = f[i];
212 j[i * 8 + 6] = g[i];
213 j[i * 8 + 7] = h[i];
214 }
215 }
216
217 /* { dg-final { scan-assembler-times {vlseg2e8\.v} 8 } } */
218 /* { dg-final { scan-assembler-times {vlseg3e8\.v} 8 } } */
219 /* { dg-final { scan-assembler-times {vlseg4e8\.v} 8 } } */
220 /* { dg-final { scan-assembler-times {vlseg5e8\.v} 8 } } */
221 /* { dg-final { scan-assembler-times {vlseg6e8\.v} 8 } } */
222 /* { dg-final { scan-assembler-times {vlseg7e8\.v} 4 } } */
223 /* { dg-final { scan-assembler-times {vlseg8e8\.v} 4 } } */
224 /* { dg-final { scan-assembler-times {vsseg2e8\.v} 8 } } */
225 /* { dg-final { scan-assembler-times {vsseg3e8\.v} 8 } } */
226 /* { dg-final { scan-assembler-times {vsseg4e8\.v} 4 } } */
227 /* { dg-final { scan-assembler-times {vsseg5e8\.v} 4 } } */
228 /* { dg-final { scan-assembler-times {vsseg6e8\.v} 4 } } */
229 /* { dg-final { scan-assembler-times {vsseg7e8\.v} 4 } } */
230 /* { dg-final { scan-assembler-times {vsseg8e8\.v} 2 } } */
231 /* { dg-final { scan-assembler-times {vsetivli\s+zero,\s*16,\s*e8,\s*m1,\s*t[au],\s*m[au]} 14 } } */
232 /* { dg-final { scan-assembler-not {vsetvli} } } */