]>
Commit | Line | Data |
---|---|---|
91e2854b JP |
1 | From a216daaa30bc8949086a16e7656f2025b692d03c Mon Sep 17 00:00:00 2001 |
2 | From: Richard Sandiford <richard.sandiford@arm.com> | |
3 | Date: Mon, 3 Aug 2020 09:48:36 +0100 | |
4 | Subject: [PATCH] c: Fix bogus vector initialisation error [PR96377] | |
5 | ||
6 | One of the problems in this PR was that if we had: | |
7 | ||
8 | vector_type1 array[] = { vector_value1 }; | |
9 | ||
10 | process_init_element would only treat vector_value1 as initialising | |
11 | a vector_type1 if they had the same TYPE_MAIN_VARIANT. This has | |
12 | several problems: | |
13 | ||
14 | (1) It gives confusing error messages if the vector types are | |
15 | incompatible. (Tested by gcc.dg/pr96377-1.c.) | |
16 | ||
17 | (2) It means that we reject code that should be valid with | |
18 | -flax-vector-conversions. (Tested by gcc.dg/pr96377-2.c.) | |
19 | ||
20 | (3) On arm and aarch64 targets, it means that we reject some | |
21 | initializers that mix Advanced SIMD and standard GNU vectors. | |
22 | These vectors have traditionally had different TYPE_MAIN_VARIANTs | |
23 | because they have different mangling schemes. (Tested by | |
24 | gcc.dg/pr96377-[3-6].c.) | |
25 | ||
26 | (4) It means that we reject SVE initializers that should be valid. | |
27 | (Tested by gcc.target/aarch64/sve/gnu_vectors_[34].c.) | |
28 | ||
29 | (5) After r11-1741-g:31427b974ed7b7dd54e2 we reject: | |
30 | ||
31 | arm_neon_type1 array[] = { k ^ arm_neon_value1 }; | |
32 | ||
33 | because applying the binary operator to arm_neon_value1 strips | |
34 | the "Advanced SIMD type" attributes that were added in that patch. | |
35 | Stripping the attributes is problematic for other reasons though, | |
36 | so that still needs to be fixed separately. | |
37 | ||
38 | g++.target/aarch64/sve/gnu_vectors_[34].C already pass. | |
39 | ||
40 | gcc/c/ | |
41 | PR c/96377 | |
42 | * c-typeck.c (process_init_element): Split test for whether to | |
43 | recurse into a record, union or array into... | |
44 | (initialize_elementwise_p): ...this new function. Don't recurse | |
45 | into a vector type if the initialization value is also a vector. | |
46 | ||
47 | gcc/testsuite/ | |
48 | PR c/96377 | |
49 | * gcc.dg/pr96377-1.c: New test. | |
50 | * gcc.dg/pr96377-2.c: Likewise. | |
51 | * gcc.dg/pr96377-3.c: Likewise. | |
52 | * gcc.dg/pr96377-4.c: Likewise. | |
53 | * gcc.dg/pr96377-5.c: Likewise. | |
54 | * gcc.dg/pr96377-6.c: Likewise. | |
55 | * gcc.target/aarch64/pr96377-1.c: Likewise. | |
56 | * gcc.target/aarch64/sve/acle/general-c/gnu_vectors_3.c: Likewise. | |
57 | * gcc.target/aarch64/sve/acle/general-c/gnu_vectors_4.c: Likewise. | |
58 | * g++.target/aarch64/sve/acle/general-c++/gnu_vectors_3.C: Likewise. | |
59 | * g++.target/aarch64/sve/acle/general-c++/gnu_vectors_4.C: Likewise. | |
60 | ||
61 | (cherry picked from commit 7d599ad27b9bcf5165f87710f1abc64bbabd06ae) | |
62 | --- | |
63 | gcc/c/c-typeck.c | 59 ++++++++++++++----- | |
64 | .../sve/acle/general-c++/gnu_vectors_3.C | 15 +++++ | |
65 | .../sve/acle/general-c++/gnu_vectors_4.C | 15 +++++ | |
66 | gcc/testsuite/gcc.dg/pr96377-1.c | 32 ++++++++++ | |
67 | gcc/testsuite/gcc.dg/pr96377-2.c | 31 ++++++++++ | |
68 | gcc/testsuite/gcc.dg/pr96377-3.c | 33 +++++++++++ | |
69 | gcc/testsuite/gcc.dg/pr96377-4.c | 32 ++++++++++ | |
70 | gcc/testsuite/gcc.dg/pr96377-5.c | 33 +++++++++++ | |
71 | gcc/testsuite/gcc.dg/pr96377-6.c | 32 ++++++++++ | |
72 | gcc/testsuite/gcc.target/aarch64/pr96377-1.c | 20 +++++++ | |
73 | .../sve/acle/general-c/gnu_vectors_3.c | 15 +++++ | |
74 | .../sve/acle/general-c/gnu_vectors_4.c | 15 +++++ | |
75 | 12 files changed, 317 insertions(+), 15 deletions(-) | |
76 | create mode 100644 gcc/testsuite/g++.target/aarch64/sve/acle/general-c++/gnu_vectors_3.C | |
77 | create mode 100644 gcc/testsuite/g++.target/aarch64/sve/acle/general-c++/gnu_vectors_4.C | |
78 | create mode 100644 gcc/testsuite/gcc.dg/pr96377-1.c | |
79 | create mode 100644 gcc/testsuite/gcc.dg/pr96377-2.c | |
80 | create mode 100644 gcc/testsuite/gcc.dg/pr96377-3.c | |
81 | create mode 100644 gcc/testsuite/gcc.dg/pr96377-4.c | |
82 | create mode 100644 gcc/testsuite/gcc.dg/pr96377-5.c | |
83 | create mode 100644 gcc/testsuite/gcc.dg/pr96377-6.c | |
84 | create mode 100644 gcc/testsuite/gcc.target/aarch64/pr96377-1.c | |
85 | create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_3.c | |
86 | create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_4.c | |
87 | ||
88 | diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c | |
89 | index eb4b641e6bb..58762f10a93 100644 | |
90 | --- a/gcc/c/c-typeck.c | |
91 | +++ b/gcc/c/c-typeck.c | |
92 | @@ -9910,6 +9910,47 @@ output_pending_init_elements (int all, struct obstack * braced_init_obstack) | |
93 | goto retry; | |
94 | } | |
95 | \f | |
96 | +/* Expression VALUE coincides with the start of type TYPE in a braced | |
97 | + initializer. Return true if we should treat VALUE as initializing | |
98 | + the first element of TYPE, false if we should treat it as initializing | |
99 | + TYPE as a whole. | |
100 | + | |
101 | + If the initializer is clearly invalid, the question becomes: | |
102 | + which choice gives the best error message? */ | |
103 | + | |
104 | +static bool | |
105 | +initialize_elementwise_p (tree type, tree value) | |
106 | +{ | |
107 | + if (type == error_mark_node || value == error_mark_node) | |
108 | + return false; | |
109 | + | |
110 | + gcc_checking_assert (TYPE_MAIN_VARIANT (type) == type); | |
111 | + | |
112 | + tree value_type = TREE_TYPE (value); | |
113 | + if (value_type == error_mark_node) | |
114 | + return false; | |
115 | + | |
116 | + /* GNU vectors can be initialized elementwise. However, treat any | |
117 | + kind of vector value as initializing the vector type as a whole, | |
118 | + regardless of whether the value is a GNU vector. Such initializers | |
119 | + are valid if and only if they would have been valid in a non-braced | |
120 | + initializer like: | |
121 | + | |
122 | + TYPE foo = VALUE; | |
123 | + | |
124 | + so recursing into the vector type would be at best confusing or at | |
125 | + worst wrong. For example, when -flax-vector-conversions is in effect, | |
126 | + it's possible to initialize a V8HI from a V4SI, even though the vectors | |
127 | + have different element types and different numbers of elements. */ | |
128 | + if (gnu_vector_type_p (type)) | |
129 | + return !VECTOR_TYPE_P (value_type); | |
130 | + | |
131 | + if (AGGREGATE_TYPE_P (type)) | |
132 | + return type != TYPE_MAIN_VARIANT (value_type); | |
133 | + | |
134 | + return false; | |
135 | +} | |
136 | + | |
137 | /* Add one non-braced element to the current constructor level. | |
138 | This adjusts the current position within the constructor's type. | |
139 | This may also start or terminate implicit levels | |
140 | @@ -10089,11 +10130,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit, | |
141 | /* Otherwise, if we have come to a subaggregate, | |
142 | and we don't have an element of its type, push into it. */ | |
143 | else if (value.value != NULL_TREE | |
144 | - && value.value != error_mark_node | |
145 | - && TYPE_MAIN_VARIANT (TREE_TYPE (value.value)) != fieldtype | |
146 | - && (fieldcode == RECORD_TYPE || fieldcode == ARRAY_TYPE | |
147 | - || fieldcode == UNION_TYPE | |
148 | - || gnu_vector_type_p (fieldtype))) | |
149 | + && initialize_elementwise_p (fieldtype, value.value)) | |
150 | { | |
151 | push_init_level (loc, 1, braced_init_obstack); | |
152 | continue; | |
153 | @@ -10181,11 +10218,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit, | |
154 | /* Otherwise, if we have come to a subaggregate, | |
155 | and we don't have an element of its type, push into it. */ | |
156 | else if (value.value != NULL_TREE | |
157 | - && value.value != error_mark_node | |
158 | - && TYPE_MAIN_VARIANT (TREE_TYPE (value.value)) != fieldtype | |
159 | - && (fieldcode == RECORD_TYPE || fieldcode == ARRAY_TYPE | |
160 | - || fieldcode == UNION_TYPE | |
161 | - || gnu_vector_type_p (fieldtype))) | |
162 | + && initialize_elementwise_p (fieldtype, value.value)) | |
163 | { | |
164 | push_init_level (loc, 1, braced_init_obstack); | |
165 | continue; | |
166 | @@ -10224,11 +10257,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit, | |
167 | /* Otherwise, if we have come to a subaggregate, | |
168 | and we don't have an element of its type, push into it. */ | |
169 | else if (value.value != NULL_TREE | |
170 | - && value.value != error_mark_node | |
171 | - && TYPE_MAIN_VARIANT (TREE_TYPE (value.value)) != elttype | |
172 | - && (eltcode == RECORD_TYPE || eltcode == ARRAY_TYPE | |
173 | - || eltcode == UNION_TYPE | |
174 | - || gnu_vector_type_p (elttype))) | |
175 | + && initialize_elementwise_p (elttype, value.value)) | |
176 | { | |
177 | push_init_level (loc, 1, braced_init_obstack); | |
178 | continue; | |
179 | diff --git a/gcc/testsuite/g++.target/aarch64/sve/acle/general-c++/gnu_vectors_3.C b/gcc/testsuite/g++.target/aarch64/sve/acle/general-c++/gnu_vectors_3.C | |
180 | new file mode 100644 | |
181 | index 00000000000..e607d58d726 | |
182 | --- /dev/null | |
183 | +++ b/gcc/testsuite/g++.target/aarch64/sve/acle/general-c++/gnu_vectors_3.C | |
184 | @@ -0,0 +1,15 @@ | |
185 | +/* { dg-options "-msve-vector-bits=256" } */ | |
186 | + | |
187 | +#include <arm_sve.h> | |
188 | + | |
189 | +typedef uint8_t gnu_uint8_t __attribute__ ((vector_size (32))); | |
190 | +typedef int8_t gnu_int8_t __attribute__ ((vector_size (32))); | |
191 | + | |
192 | +void | |
193 | +f (svuint8_t sve_u1, svint8_t sve_s1, | |
194 | + gnu_uint8_t gnu_u1, gnu_int8_t gnu_s1) | |
195 | +{ | |
196 | + gnu_uint8_t arr1[] = { gnu_u1, sve_u1 }; | |
197 | + gnu_uint8_t arr2[] = { gnu_s1 }; // { dg-error "cannot convert" } | |
198 | + gnu_uint8_t arr3[] = { sve_s1 }; // { dg-error "cannot convert" } | |
199 | +} | |
200 | diff --git a/gcc/testsuite/g++.target/aarch64/sve/acle/general-c++/gnu_vectors_4.C b/gcc/testsuite/g++.target/aarch64/sve/acle/general-c++/gnu_vectors_4.C | |
201 | new file mode 100644 | |
202 | index 00000000000..ac4e0d12ff8 | |
203 | --- /dev/null | |
204 | +++ b/gcc/testsuite/g++.target/aarch64/sve/acle/general-c++/gnu_vectors_4.C | |
205 | @@ -0,0 +1,15 @@ | |
206 | +/* { dg-options "-msve-vector-bits=256 -flax-vector-conversions" } */ | |
207 | + | |
208 | +#include <arm_sve.h> | |
209 | + | |
210 | +typedef uint8_t gnu_uint8_t __attribute__ ((vector_size (32))); | |
211 | +typedef int8_t gnu_int8_t __attribute__ ((vector_size (32))); | |
212 | + | |
213 | +void | |
214 | +f (svuint8_t sve_u1, svint8_t sve_s1, | |
215 | + gnu_uint8_t gnu_u1, gnu_int8_t gnu_s1) | |
216 | +{ | |
217 | + gnu_uint8_t arr1[] = { gnu_u1, sve_u1 }; | |
218 | + gnu_uint8_t arr2[] = { gnu_s1 }; | |
219 | + gnu_uint8_t arr3[] = { sve_s1 }; | |
220 | +} | |
221 | diff --git a/gcc/testsuite/gcc.dg/pr96377-1.c b/gcc/testsuite/gcc.dg/pr96377-1.c | |
222 | new file mode 100644 | |
223 | index 00000000000..2bf3f816331 | |
224 | --- /dev/null | |
225 | +++ b/gcc/testsuite/gcc.dg/pr96377-1.c | |
226 | @@ -0,0 +1,32 @@ | |
227 | +/* { dg-options "-fno-lax-vector-conversions" } */ | |
228 | +/* { dg-message "use '-flax-vector-conversions' to permit conversions" "" { target *-*-* } 0 } */ | |
229 | + | |
230 | +typedef int v4si __attribute__((vector_size(16))); | |
231 | +typedef short v8hi __attribute__((vector_size(16))); | |
232 | + | |
233 | +struct s { v8hi x; v4si y; }; | |
234 | +union u1 { v8hi x; v4si y; }; | |
235 | +union u2 { v4si s; v8hi y; }; | |
236 | + | |
237 | +void | |
238 | +foo (v4si i, v8hi h) | |
239 | +{ | |
240 | + struct s x1 = { i, i }; // { dg-error "incompatible types when initializing type '__vector" } | |
241 | + struct s x2 = { h, h }; // { dg-error "incompatible types" } | |
242 | + struct s x3 = { i, h }; // { dg-error "incompatible types" } | |
243 | + struct s x4 = { h, i }; | |
244 | + | |
245 | + union u1 y1 = { i }; // { dg-error "incompatible types" } | |
246 | + union u1 y2 = { h }; | |
247 | + union u2 y3 = { i }; | |
248 | + union u2 y4 = { h }; // { dg-error "incompatible types" } | |
249 | + | |
250 | + v4si z1[] = { i, i }; | |
251 | + v4si z2[] = { i, h }; // { dg-error "incompatible types" } | |
252 | + v4si z3[] = { h, i }; // { dg-error "incompatible types" } | |
253 | + v4si z4[] = { h, h }; // { dg-error "incompatible types" } | |
254 | + v8hi z5[] = { i, i }; // { dg-error "incompatible types" } | |
255 | + v8hi z6[] = { i, h }; // { dg-error "incompatible types" } | |
256 | + v8hi z7[] = { h, i }; // { dg-error "incompatible types" } | |
257 | + v8hi z8[] = { h, h }; | |
258 | +} | |
259 | diff --git a/gcc/testsuite/gcc.dg/pr96377-2.c b/gcc/testsuite/gcc.dg/pr96377-2.c | |
260 | new file mode 100644 | |
261 | index 00000000000..f58b06d9076 | |
262 | --- /dev/null | |
263 | +++ b/gcc/testsuite/gcc.dg/pr96377-2.c | |
264 | @@ -0,0 +1,31 @@ | |
265 | +/* { dg-options "-flax-vector-conversions" } */ | |
266 | + | |
267 | +typedef int v4si __attribute__((vector_size(16))); | |
268 | +typedef short v8hi __attribute__((vector_size(16))); | |
269 | + | |
270 | +struct s { v8hi x; v4si y; }; | |
271 | +union u1 { v8hi x; v4si y; }; | |
272 | +union u2 { v4si s; v8hi y; }; | |
273 | + | |
274 | +void | |
275 | +foo (v4si i, v8hi h) | |
276 | +{ | |
277 | + struct s x1 = { i, i }; | |
278 | + struct s x2 = { h, h }; | |
279 | + struct s x3 = { i, h }; | |
280 | + struct s x4 = { h, i }; | |
281 | + | |
282 | + union u1 y1 = { i }; | |
283 | + union u1 y2 = { h }; | |
284 | + union u2 y3 = { i }; | |
285 | + union u2 y4 = { h }; | |
286 | + | |
287 | + v4si z1[] = { i, i }; | |
288 | + v4si z2[] = { i, h }; | |
289 | + v4si z3[] = { h, i }; | |
290 | + v4si z4[] = { h, h }; | |
291 | + v8hi z5[] = { i, i }; | |
292 | + v8hi z6[] = { i, h }; | |
293 | + v8hi z7[] = { h, i }; | |
294 | + v8hi z8[] = { h, h }; | |
295 | +} | |
296 | diff --git a/gcc/testsuite/gcc.dg/pr96377-3.c b/gcc/testsuite/gcc.dg/pr96377-3.c | |
297 | new file mode 100644 | |
298 | index 00000000000..66dce01f277 | |
299 | --- /dev/null | |
300 | +++ b/gcc/testsuite/gcc.dg/pr96377-3.c | |
301 | @@ -0,0 +1,33 @@ | |
302 | +/* { dg-do compile { target aarch64*-*-* } } */ | |
303 | +/* { dg-options "-fno-lax-vector-conversions" } */ | |
304 | +/* { dg-message "use '-flax-vector-conversions' to permit conversions" "" { target *-*-* } 0 } */ | |
305 | + | |
306 | +typedef int v4si __attribute__((vector_size(16))); | |
307 | +typedef short v8hi __attribute__((vector_size(16))); | |
308 | + | |
309 | +struct s { v8hi x; v4si y; }; | |
310 | +union u1 { v8hi x; v4si y; }; | |
311 | +union u2 { v4si s; v8hi y; }; | |
312 | + | |
313 | +void | |
314 | +foo (__Int32x4_t i, __Int16x8_t h) | |
315 | +{ | |
316 | + struct s x1 = { i, i }; // { dg-error "incompatible types when initializing type '__vector" } | |
317 | + struct s x2 = { h, h }; // { dg-error "incompatible types" } | |
318 | + struct s x3 = { i, h }; // { dg-error "incompatible types" } | |
319 | + struct s x4 = { h, i }; | |
320 | + | |
321 | + union u1 y1 = { i }; // { dg-error "incompatible types" } | |
322 | + union u1 y2 = { h }; | |
323 | + union u2 y3 = { i }; | |
324 | + union u2 y4 = { h }; // { dg-error "incompatible types" } | |
325 | + | |
326 | + v4si z1[] = { i, i }; | |
327 | + v4si z2[] = { i, h }; // { dg-error "incompatible types" } | |
328 | + v4si z3[] = { h, i }; // { dg-error "incompatible types" } | |
329 | + v4si z4[] = { h, h }; // { dg-error "incompatible types" } | |
330 | + v8hi z5[] = { i, i }; // { dg-error "incompatible types" } | |
331 | + v8hi z6[] = { i, h }; // { dg-error "incompatible types" } | |
332 | + v8hi z7[] = { h, i }; // { dg-error "incompatible types" } | |
333 | + v8hi z8[] = { h, h }; | |
334 | +} | |
335 | diff --git a/gcc/testsuite/gcc.dg/pr96377-4.c b/gcc/testsuite/gcc.dg/pr96377-4.c | |
336 | new file mode 100644 | |
337 | index 00000000000..f7aaf490031 | |
338 | --- /dev/null | |
339 | +++ b/gcc/testsuite/gcc.dg/pr96377-4.c | |
340 | @@ -0,0 +1,32 @@ | |
341 | +/* { dg-do compile { target aarch64*-*-* } } */ | |
342 | +/* { dg-options "-flax-vector-conversions" } */ | |
343 | + | |
344 | +typedef int v4si __attribute__((vector_size(16))); | |
345 | +typedef short v8hi __attribute__((vector_size(16))); | |
346 | + | |
347 | +struct s { v8hi x; v4si y; }; | |
348 | +union u1 { v8hi x; v4si y; }; | |
349 | +union u2 { v4si s; v8hi y; }; | |
350 | + | |
351 | +void | |
352 | +foo (__Int32x4_t i, __Int16x8_t h) | |
353 | +{ | |
354 | + struct s x1 = { i, i }; | |
355 | + struct s x2 = { h, h }; | |
356 | + struct s x3 = { i, h }; | |
357 | + struct s x4 = { h, i }; | |
358 | + | |
359 | + union u1 y1 = { i }; | |
360 | + union u1 y2 = { h }; | |
361 | + union u2 y3 = { i }; | |
362 | + union u2 y4 = { h }; | |
363 | + | |
364 | + v4si z1[] = { i, i }; | |
365 | + v4si z2[] = { i, h }; | |
366 | + v4si z3[] = { h, i }; | |
367 | + v4si z4[] = { h, h }; | |
368 | + v8hi z5[] = { i, i }; | |
369 | + v8hi z6[] = { i, h }; | |
370 | + v8hi z7[] = { h, i }; | |
371 | + v8hi z8[] = { h, h }; | |
372 | +} | |
373 | diff --git a/gcc/testsuite/gcc.dg/pr96377-5.c b/gcc/testsuite/gcc.dg/pr96377-5.c | |
374 | new file mode 100644 | |
375 | index 00000000000..3d0c24befa6 | |
376 | --- /dev/null | |
377 | +++ b/gcc/testsuite/gcc.dg/pr96377-5.c | |
378 | @@ -0,0 +1,33 @@ | |
379 | +/* { dg-do compile { target aarch64*-*-* } } */ | |
380 | +/* { dg-options "-fno-lax-vector-conversions" } */ | |
381 | +/* { dg-message "use '-flax-vector-conversions' to permit conversions" "" { target *-*-* } 0 } */ | |
382 | + | |
383 | +typedef int v4si __attribute__((vector_size(16))); | |
384 | +typedef short v8hi __attribute__((vector_size(16))); | |
385 | + | |
386 | +struct s { __Int16x8_t x; __Int32x4_t y; }; | |
387 | +union u1 { __Int16x8_t x; __Int32x4_t y; }; | |
388 | +union u2 { __Int32x4_t s; __Int16x8_t y; }; | |
389 | + | |
390 | +void | |
391 | +foo (v4si i, v8hi h) | |
392 | +{ | |
393 | + struct s x1 = { i, i }; // { dg-error "incompatible types when initializing type '__Int16x8_t" } | |
394 | + struct s x2 = { h, h }; // { dg-error "incompatible types" } | |
395 | + struct s x3 = { i, h }; // { dg-error "incompatible types" } | |
396 | + struct s x4 = { h, i }; | |
397 | + | |
398 | + union u1 y1 = { i }; // { dg-error "incompatible types" } | |
399 | + union u1 y2 = { h }; | |
400 | + union u2 y3 = { i }; | |
401 | + union u2 y4 = { h }; // { dg-error "incompatible types" } | |
402 | + | |
403 | + v4si z1[] = { i, i }; | |
404 | + v4si z2[] = { i, h }; // { dg-error "incompatible types" } | |
405 | + v4si z3[] = { h, i }; // { dg-error "incompatible types" } | |
406 | + v4si z4[] = { h, h }; // { dg-error "incompatible types" } | |
407 | + v8hi z5[] = { i, i }; // { dg-error "incompatible types" } | |
408 | + v8hi z6[] = { i, h }; // { dg-error "incompatible types" } | |
409 | + v8hi z7[] = { h, i }; // { dg-error "incompatible types" } | |
410 | + v8hi z8[] = { h, h }; | |
411 | +} | |
412 | diff --git a/gcc/testsuite/gcc.dg/pr96377-6.c b/gcc/testsuite/gcc.dg/pr96377-6.c | |
413 | new file mode 100644 | |
414 | index 00000000000..165327fa292 | |
415 | --- /dev/null | |
416 | +++ b/gcc/testsuite/gcc.dg/pr96377-6.c | |
417 | @@ -0,0 +1,32 @@ | |
418 | +/* { dg-do compile { target aarch64*-*-* } } */ | |
419 | +/* { dg-options "-flax-vector-conversions" } */ | |
420 | + | |
421 | +typedef int v4si __attribute__((vector_size(16))); | |
422 | +typedef short v8hi __attribute__((vector_size(16))); | |
423 | + | |
424 | +struct s { __Int16x8_t x; __Int32x4_t y; }; | |
425 | +union u1 { __Int16x8_t x; __Int32x4_t y; }; | |
426 | +union u2 { __Int32x4_t s; __Int16x8_t y; }; | |
427 | + | |
428 | +void | |
429 | +foo (v4si i, v8hi h) | |
430 | +{ | |
431 | + struct s x1 = { i, i }; | |
432 | + struct s x2 = { h, h }; | |
433 | + struct s x3 = { i, h }; | |
434 | + struct s x4 = { h, i }; | |
435 | + | |
436 | + union u1 y1 = { i }; | |
437 | + union u1 y2 = { h }; | |
438 | + union u2 y3 = { i }; | |
439 | + union u2 y4 = { h }; | |
440 | + | |
441 | + v4si z1[] = { i, i }; | |
442 | + v4si z2[] = { i, h }; | |
443 | + v4si z3[] = { h, i }; | |
444 | + v4si z4[] = { h, h }; | |
445 | + v8hi z5[] = { i, i }; | |
446 | + v8hi z6[] = { i, h }; | |
447 | + v8hi z7[] = { h, i }; | |
448 | + v8hi z8[] = { h, h }; | |
449 | +} | |
450 | diff --git a/gcc/testsuite/gcc.target/aarch64/pr96377-1.c b/gcc/testsuite/gcc.target/aarch64/pr96377-1.c | |
451 | new file mode 100644 | |
452 | index 00000000000..51e3e36edfc | |
453 | --- /dev/null | |
454 | +++ b/gcc/testsuite/gcc.target/aarch64/pr96377-1.c | |
455 | @@ -0,0 +1,20 @@ | |
456 | +/* { dg-options "" } */ | |
457 | + | |
458 | +#include <arm_neon.h> | |
459 | + | |
460 | +struct aegis128_state { | |
461 | + uint8x16_t v[5]; | |
462 | +}; | |
463 | + | |
464 | +void foo(const void *key, const void *iv, const void *const0, const void *const1) | |
465 | +{ | |
466 | + uint8x16_t k = vld1q_u8(key); | |
467 | + uint8x16_t kiv = k ^ vld1q_u8(iv); | |
468 | + struct aegis128_state st = {{ | |
469 | + kiv, | |
470 | + vld1q_u8(const1), | |
471 | + vld1q_u8(const0), | |
472 | + k ^ vld1q_u8(const0), | |
473 | + k ^ vld1q_u8(const1), | |
474 | + }}; | |
475 | +} | |
476 | diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_3.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_3.c | |
477 | new file mode 100644 | |
478 | index 00000000000..0f1a2b0e46b | |
479 | --- /dev/null | |
480 | +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_3.c | |
481 | @@ -0,0 +1,15 @@ | |
482 | +/* { dg-options "-msve-vector-bits=256" } */ | |
483 | + | |
484 | +#include <arm_sve.h> | |
485 | + | |
486 | +typedef uint8_t gnu_uint8_t __attribute__ ((vector_size (32))); | |
487 | +typedef int8_t gnu_int8_t __attribute__ ((vector_size (32))); | |
488 | + | |
489 | +void | |
490 | +f (svuint8_t sve_u1, svint8_t sve_s1, | |
491 | + gnu_uint8_t gnu_u1, gnu_int8_t gnu_s1) | |
492 | +{ | |
493 | + gnu_uint8_t arr1[] = { gnu_u1, sve_u1 }; | |
494 | + gnu_uint8_t arr2[] = { gnu_s1 }; // { dg-error "incompatible types" } | |
495 | + gnu_uint8_t arr3[] = { sve_s1 }; // { dg-error "incompatible types" } | |
496 | +} | |
497 | diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_4.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_4.c | |
498 | new file mode 100644 | |
499 | index 00000000000..ac4e0d12ff8 | |
500 | --- /dev/null | |
501 | +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_4.c | |
502 | @@ -0,0 +1,15 @@ | |
503 | +/* { dg-options "-msve-vector-bits=256 -flax-vector-conversions" } */ | |
504 | + | |
505 | +#include <arm_sve.h> | |
506 | + | |
507 | +typedef uint8_t gnu_uint8_t __attribute__ ((vector_size (32))); | |
508 | +typedef int8_t gnu_int8_t __attribute__ ((vector_size (32))); | |
509 | + | |
510 | +void | |
511 | +f (svuint8_t sve_u1, svint8_t sve_s1, | |
512 | + gnu_uint8_t gnu_u1, gnu_int8_t gnu_s1) | |
513 | +{ | |
514 | + gnu_uint8_t arr1[] = { gnu_u1, sve_u1 }; | |
515 | + gnu_uint8_t arr2[] = { gnu_s1 }; | |
516 | + gnu_uint8_t arr3[] = { sve_s1 }; | |
517 | +} | |
518 | -- | |
519 | 2.18.4 | |
520 |