Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / attr-riscv-rvv-vector-bits.c
blobfe507a102cee1e6923d616b143e21f0c66307ef5
1 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -ffreestanding -fsyntax-only -verify -mvscale-min=1 -mvscale-max=1 %s
2 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -ffreestanding -fsyntax-only -verify -mvscale-min=2 -mvscale-max=2 %s
3 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -ffreestanding -fsyntax-only -verify -mvscale-min=4 -mvscale-max=4 %s
4 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -ffreestanding -fsyntax-only -verify -mvscale-min=8 -mvscale-max=8 %s
5 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -ffreestanding -fsyntax-only -verify -mvscale-min=16 -mvscale-max=16 %s
7 #include <stdint.h>
9 typedef __rvv_bool64_t vbool64_t;
10 typedef __rvv_bool32_t vbool32_t;
11 typedef __rvv_bool16_t vbool16_t;
12 typedef __rvv_bool8_t vbool8_t;
13 typedef __rvv_bool4_t vbool4_t;
14 typedef __rvv_bool2_t vbool2_t;
15 typedef __rvv_bool1_t vbool1_t;
17 typedef __rvv_int8mf8_t vint8mf8_t;
18 typedef __rvv_uint8mf8_t vuint8mf8_t;
20 typedef __rvv_int8mf4_t vint8mf4_t;
21 typedef __rvv_uint8mf4_t vuint8mf4_t;
22 typedef __rvv_int16mf4_t vint16mf4_t;
23 typedef __rvv_uint16mf4_t vuint16mf4_t;
25 typedef __rvv_int8mf2_t vint8mf2_t;
26 typedef __rvv_uint8mf2_t vuint8mf2_t;
27 typedef __rvv_int16mf2_t vint16mf2_t;
28 typedef __rvv_uint16mf2_t vuint16mf2_t;
29 typedef __rvv_int32mf2_t vint32mf2_t;
30 typedef __rvv_uint32mf2_t vuint32mf2_t;
31 typedef __rvv_float32mf2_t vfloat32mf2_t;
33 typedef __rvv_int8m1_t vint8m1_t;
34 typedef __rvv_uint8m1_t vuint8m1_t;
35 typedef __rvv_int16m1_t vint16m1_t;
36 typedef __rvv_uint16m1_t vuint16m1_t;
37 typedef __rvv_int32m1_t vint32m1_t;
38 typedef __rvv_uint32m1_t vuint32m1_t;
39 typedef __rvv_int64m1_t vint64m1_t;
40 typedef __rvv_uint64m1_t vuint64m1_t;
41 typedef __rvv_float32m1_t vfloat32m1_t;
42 typedef __rvv_float64m1_t vfloat64m1_t;
44 typedef __rvv_int8m2_t vint8m2_t;
45 typedef __rvv_uint8m2_t vuint8m2_t;
46 typedef __rvv_int16m2_t vint16m2_t;
47 typedef __rvv_uint16m2_t vuint16m2_t;
48 typedef __rvv_int32m2_t vint32m2_t;
49 typedef __rvv_uint32m2_t vuint32m2_t;
50 typedef __rvv_int64m2_t vint64m2_t;
51 typedef __rvv_uint64m2_t vuint64m2_t;
52 typedef __rvv_float32m2_t vfloat32m2_t;
53 typedef __rvv_float64m2_t vfloat64m2_t;
55 typedef __rvv_int8m4_t vint8m4_t;
56 typedef __rvv_uint8m4_t vuint8m4_t;
57 typedef __rvv_int16m4_t vint16m4_t;
58 typedef __rvv_uint16m4_t vuint16m4_t;
59 typedef __rvv_int32m4_t vint32m4_t;
60 typedef __rvv_uint32m4_t vuint32m4_t;
61 typedef __rvv_int64m4_t vint64m4_t;
62 typedef __rvv_uint64m4_t vuint64m4_t;
63 typedef __rvv_float32m4_t vfloat32m4_t;
64 typedef __rvv_float64m4_t vfloat64m4_t;
66 typedef __rvv_int8m8_t vint8m8_t;
67 typedef __rvv_uint8m8_t vuint8m8_t;
68 typedef __rvv_int16m8_t vint16m8_t;
69 typedef __rvv_uint16m8_t vuint16m8_t;
70 typedef __rvv_int32m8_t vint32m8_t;
71 typedef __rvv_uint32m8_t vuint32m8_t;
72 typedef __rvv_int64m8_t vint64m8_t;
73 typedef __rvv_uint64m8_t vuint64m8_t;
74 typedef __rvv_float32m8_t vfloat32m8_t;
75 typedef __rvv_float64m8_t vfloat64m8_t;
77 // Define valid fixed-width RVV types
78 typedef vint8mf8_t fixed_int8mf8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 8)));
80 typedef vuint8mf8_t fixed_uint8mf8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 8)));
82 typedef vint8mf4_t fixed_int8mf4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4)));
83 typedef vint16mf4_t fixed_int16mf4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4)));
85 typedef vuint8mf4_t fixed_uint8mf4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4)));
86 typedef vuint16mf4_t fixed_uint16mf4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4)));
88 typedef vint8mf2_t fixed_int8mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));
89 typedef vint16mf2_t fixed_int16mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));
90 typedef vint32mf2_t fixed_int32mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));
92 typedef vuint8mf2_t fixed_uint8mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));
93 typedef vuint16mf2_t fixed_uint16mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));
94 typedef vuint32mf2_t fixed_uint32mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));
96 typedef vfloat32mf2_t fixed_float32mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));
98 typedef vint8m1_t fixed_int8m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
99 typedef vint16m1_t fixed_int16m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
100 typedef vint32m1_t fixed_int32m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
101 typedef vint64m1_t fixed_int64m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
103 typedef vuint8m1_t fixed_uint8m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
104 typedef vuint16m1_t fixed_uint16m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
105 typedef vuint32m1_t fixed_uint32m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
106 typedef vuint64m1_t fixed_uint64m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
108 typedef vfloat32m1_t fixed_float32m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
109 typedef vfloat64m1_t fixed_float64m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
111 typedef vint8m2_t fixed_int8m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));
112 typedef vint16m2_t fixed_int16m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));
113 typedef vint32m2_t fixed_int32m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));
114 typedef vint64m2_t fixed_int64m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));
116 typedef vuint8m2_t fixed_uint8m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));
117 typedef vuint16m2_t fixed_uint16m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));
118 typedef vuint32m2_t fixed_uint32m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));
119 typedef vuint64m2_t fixed_uint64m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));
121 typedef vfloat32m2_t fixed_float32m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));
122 typedef vfloat64m2_t fixed_float64m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));
124 typedef vint8m4_t fixed_int8m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));
125 typedef vint16m4_t fixed_int16m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));
126 typedef vint32m4_t fixed_int32m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));
127 typedef vint64m4_t fixed_int64m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));
129 typedef vuint8m4_t fixed_uint8m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));
130 typedef vuint16m4_t fixed_uint16m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));
131 typedef vuint32m4_t fixed_uint32m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));
132 typedef vuint64m4_t fixed_uint64m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));
134 typedef vfloat32m4_t fixed_float32m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));
135 typedef vfloat64m4_t fixed_float64m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));
137 typedef vint8m8_t fixed_int8m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));
138 typedef vint16m8_t fixed_int16m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));
139 typedef vint32m8_t fixed_int32m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));
140 typedef vint64m8_t fixed_int64m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));
142 typedef vuint8m8_t fixed_uint8m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));
143 typedef vuint16m8_t fixed_uint16m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));
144 typedef vuint32m8_t fixed_uint32m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));
145 typedef vuint64m8_t fixed_uint64m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));
147 typedef vfloat32m8_t fixed_float32m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));
148 typedef vfloat64m8_t fixed_float64m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));
150 // GNU vector types
151 typedef int8_t gnu_int8mf8_t __attribute__((vector_size(__riscv_v_fixed_vlen / 64)));
153 typedef uint8_t gnu_uint8mf8_t __attribute__((vector_size(__riscv_v_fixed_vlen / 64)));
155 typedef int8_t gnu_int8mf4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 32)));
156 typedef int16_t gnu_int16mf4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 32)));
158 typedef uint8_t gnu_uint8mf4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 32)));
159 typedef uint16_t gnu_uint16mf4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 32)));
161 typedef int8_t gnu_int8mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));
162 typedef int16_t gnu_int16mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));
163 typedef int32_t gnu_int32mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));
165 typedef uint8_t gnu_uint8mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));
166 typedef uint16_t gnu_uint16mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));
167 typedef uint32_t gnu_uint32mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));
169 typedef float gnu_float32mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));
171 typedef int8_t gnu_int8m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));
172 typedef int16_t gnu_int16m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));
173 typedef int32_t gnu_int32m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));
174 typedef int64_t gnu_int64m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));
176 typedef uint8_t gnu_uint8m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));
177 typedef uint16_t gnu_uint16m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));
178 typedef uint32_t gnu_uint32m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));
179 typedef uint64_t gnu_uint64m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));
181 typedef float gnu_float32m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));
182 typedef double gnu_float64m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));
184 typedef int8_t gnu_int8m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));
185 typedef int16_t gnu_int16m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));
186 typedef int32_t gnu_int32m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));
187 typedef int64_t gnu_int64m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));
189 typedef uint8_t gnu_uint8m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));
190 typedef uint16_t gnu_uint16m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));
191 typedef uint32_t gnu_uint32m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));
192 typedef uint64_t gnu_uint64m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));
194 typedef float gnu_float32m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));
195 typedef double gnu_float64m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));
197 typedef int8_t gnu_int8m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));
198 typedef int16_t gnu_int16m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));
199 typedef int32_t gnu_int32m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));
200 typedef int64_t gnu_int64m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));
202 typedef uint8_t gnu_uint8m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));
203 typedef uint16_t gnu_uint16m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));
204 typedef uint32_t gnu_uint32m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));
205 typedef uint64_t gnu_uint64m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));
207 typedef float gnu_float32m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));
208 typedef double gnu_float64m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));
210 typedef int8_t gnu_int8m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));
211 typedef int16_t gnu_int16m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));
212 typedef int32_t gnu_int32m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));
213 typedef int64_t gnu_int64m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));
215 typedef uint8_t gnu_uint8m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));
216 typedef uint16_t gnu_uint16m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));
217 typedef uint32_t gnu_uint32m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));
218 typedef uint64_t gnu_uint64m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));
220 typedef float gnu_float32m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));
221 typedef double gnu_float64m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));
223 // Attribute must have a single argument
224 typedef vint8m1_t no_argument __attribute__((riscv_rvv_vector_bits)); // expected-error {{'riscv_rvv_vector_bits' attribute takes one argument}}
225 typedef vint8m1_t two_arguments __attribute__((riscv_rvv_vector_bits(2, 4))); // expected-error {{'riscv_rvv_vector_bits' attribute takes one argument}}
227 // The number of RVV vector bits must be an integer constant expression
228 typedef vint8m1_t non_int_size1 __attribute__((riscv_rvv_vector_bits(2.0))); // expected-error {{'riscv_rvv_vector_bits' attribute requires an integer constant}}
229 typedef vint8m1_t non_int_size2 __attribute__((riscv_rvv_vector_bits("256"))); // expected-error {{'riscv_rvv_vector_bits' attribute requires an integer constant}}
231 // bool types and LMUL != 1 are not supported.
232 typedef vbool1_t fixed_vbool1_t_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 'vbool1_t'}}
234 // Attribute must be attached to a single RVV vector or predicate type.
235 typedef void *badtype1 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 'void *'}}
236 typedef int badtype2 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 'int'}}
237 typedef float badtype3 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 'float'}}
239 // Attribute only applies to typedefs.
240 vint8m1_t non_typedef_type __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // expected-error {{'riscv_rvv_vector_bits' attribute only applies to typedefs}}
242 // Test that we can define non-local fixed-length RVV types (unsupported for
243 // sizeless types).
244 fixed_int8m1_t global_int8;
246 extern fixed_int8m1_t extern_int8;
248 static fixed_int8m1_t static_int8;
250 fixed_int8m1_t *global_int8_ptr;
251 extern fixed_int8m1_t *extern_int8_ptr;
252 static fixed_int8m1_t *static_int8_ptr;
253 __thread fixed_int8m1_t thread_int8;
255 typedef fixed_int8m1_t int8_typedef;
256 typedef fixed_int8m1_t *int8_ptr_typedef;
258 // Test sized expressions
259 int sizeof_int8 = sizeof(global_int8);
260 int sizeof_int8_var = sizeof(*global_int8_ptr);
261 int sizeof_int8_var_ptr = sizeof(global_int8_ptr);
263 extern fixed_int8m1_t *extern_int8_ptr;
265 int alignof_int8 = __alignof__(extern_int8);
266 int alignof_int8_var = __alignof__(*extern_int8_ptr);
267 int alignof_int8_var_ptr = __alignof__(extern_int8_ptr);
269 void f(int c) {
270 fixed_int8m1_t fs8;
271 vint8m1_t ss8;
272 gnu_int8m1_t gs8;
274 // Check conditional expressions where the result is ambiguous are
275 // ill-formed.
276 void *sel __attribute__((unused));
277 sel = c ? ss8 : fs8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}}
278 sel = c ? fs8 : ss8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}}
280 sel = c ? gs8 : ss8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
281 sel = c ? ss8 : gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
283 sel = c ? gs8 : fs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
284 sel = c ? fs8 : gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
286 // Check binary expressions where the result is ambiguous are ill-formed.
287 ss8 = ss8 + fs8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}}
288 ss8 = ss8 + gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
290 fs8 = fs8 + ss8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}}
291 fs8 = fs8 + gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
293 gs8 = gs8 + ss8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
294 gs8 = gs8 + fs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
296 ss8 += fs8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}}
297 ss8 += gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
299 fs8 += ss8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}}
300 fs8 += gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
302 gs8 += ss8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
303 gs8 += fs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
305 ss8 = ss8 == fs8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}}
306 ss8 = ss8 == gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
308 fs8 = fs8 == ss8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}}
309 fs8 = fs8 == gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
311 gs8 = gs8 == ss8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
312 gs8 = gs8 == fs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
314 ss8 = ss8 & fs8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}}
315 ss8 = ss8 & gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
317 fs8 = fs8 & ss8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}}
318 fs8 = fs8 & gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
320 gs8 = gs8 & ss8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
321 gs8 = gs8 & fs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}}
324 // --------------------------------------------------------------------------//
325 // Sizeof
327 #define VECTOR_SIZE ((__riscv_v_fixed_vlen / 8))
329 _Static_assert(sizeof(fixed_int8mf8_t) == VECTOR_SIZE / 8, "");
331 _Static_assert(sizeof(fixed_uint8mf8_t) == VECTOR_SIZE / 8, "");
333 _Static_assert(sizeof(fixed_int8mf4_t) == VECTOR_SIZE / 4, "");
334 _Static_assert(sizeof(fixed_int16mf4_t) == VECTOR_SIZE / 4, "");
336 _Static_assert(sizeof(fixed_uint8mf4_t) == VECTOR_SIZE / 4, "");
337 _Static_assert(sizeof(fixed_uint16mf4_t) == VECTOR_SIZE / 4, "");
339 _Static_assert(sizeof(fixed_int8mf2_t) == VECTOR_SIZE / 2, "");
340 _Static_assert(sizeof(fixed_int16mf2_t) == VECTOR_SIZE / 2, "");
341 _Static_assert(sizeof(fixed_int32mf2_t) == VECTOR_SIZE / 2, "");
343 _Static_assert(sizeof(fixed_uint8mf2_t) == VECTOR_SIZE / 2, "");
344 _Static_assert(sizeof(fixed_uint16mf2_t) == VECTOR_SIZE / 2, "");
345 _Static_assert(sizeof(fixed_uint32mf2_t) == VECTOR_SIZE / 2, "");
347 _Static_assert(sizeof(fixed_float32mf2_t) == VECTOR_SIZE / 2, "");
349 _Static_assert(sizeof(fixed_int8m1_t) == VECTOR_SIZE, "");
350 _Static_assert(sizeof(fixed_int16m1_t) == VECTOR_SIZE, "");
351 _Static_assert(sizeof(fixed_int32m1_t) == VECTOR_SIZE, "");
352 _Static_assert(sizeof(fixed_int64m1_t) == VECTOR_SIZE, "");
354 _Static_assert(sizeof(fixed_uint8m1_t) == VECTOR_SIZE, "");
355 _Static_assert(sizeof(fixed_uint16m1_t) == VECTOR_SIZE, "");
356 _Static_assert(sizeof(fixed_uint32m1_t) == VECTOR_SIZE, "");
357 _Static_assert(sizeof(fixed_int64m1_t) == VECTOR_SIZE, "");
359 _Static_assert(sizeof(fixed_float32m1_t) == VECTOR_SIZE, "");
360 _Static_assert(sizeof(fixed_float64m1_t) == VECTOR_SIZE, "");
362 _Static_assert(sizeof(fixed_int8m2_t) == VECTOR_SIZE * 2, "");
363 _Static_assert(sizeof(fixed_int16m2_t) == VECTOR_SIZE * 2, "");
364 _Static_assert(sizeof(fixed_int32m2_t) == VECTOR_SIZE * 2, "");
365 _Static_assert(sizeof(fixed_int64m2_t) == VECTOR_SIZE * 2, "");
367 _Static_assert(sizeof(fixed_uint8m2_t) == VECTOR_SIZE * 2, "");
368 _Static_assert(sizeof(fixed_uint16m2_t) == VECTOR_SIZE * 2, "");
369 _Static_assert(sizeof(fixed_uint32m2_t) == VECTOR_SIZE * 2, "");
370 _Static_assert(sizeof(fixed_int64m2_t) == VECTOR_SIZE * 2, "");
372 _Static_assert(sizeof(fixed_float32m2_t) == VECTOR_SIZE * 2, "");
373 _Static_assert(sizeof(fixed_float64m2_t) == VECTOR_SIZE * 2, "");
375 _Static_assert(sizeof(fixed_int8m4_t) == VECTOR_SIZE * 4, "");
376 _Static_assert(sizeof(fixed_int16m4_t) == VECTOR_SIZE * 4, "");
377 _Static_assert(sizeof(fixed_int32m4_t) == VECTOR_SIZE * 4, "");
378 _Static_assert(sizeof(fixed_int64m4_t) == VECTOR_SIZE * 4, "");
380 _Static_assert(sizeof(fixed_uint8m4_t) == VECTOR_SIZE * 4, "");
381 _Static_assert(sizeof(fixed_uint16m4_t) == VECTOR_SIZE * 4, "");
382 _Static_assert(sizeof(fixed_uint32m4_t) == VECTOR_SIZE * 4, "");
383 _Static_assert(sizeof(fixed_int64m4_t) == VECTOR_SIZE * 4, "");
385 _Static_assert(sizeof(fixed_float32m4_t) == VECTOR_SIZE * 4, "");
386 _Static_assert(sizeof(fixed_float64m4_t) == VECTOR_SIZE * 4, "");
388 _Static_assert(sizeof(fixed_int8m8_t) == VECTOR_SIZE * 8, "");
389 _Static_assert(sizeof(fixed_int16m8_t) == VECTOR_SIZE * 8, "");
390 _Static_assert(sizeof(fixed_int32m8_t) == VECTOR_SIZE * 8, "");
391 _Static_assert(sizeof(fixed_int64m8_t) == VECTOR_SIZE * 8, "");
393 _Static_assert(sizeof(fixed_uint8m8_t) == VECTOR_SIZE * 8, "");
394 _Static_assert(sizeof(fixed_uint16m8_t) == VECTOR_SIZE * 8, "");
395 _Static_assert(sizeof(fixed_uint32m8_t) == VECTOR_SIZE * 8, "");
396 _Static_assert(sizeof(fixed_int64m8_t) == VECTOR_SIZE * 8, "");
398 _Static_assert(sizeof(fixed_float32m8_t) == VECTOR_SIZE * 8, "");
399 _Static_assert(sizeof(fixed_float64m8_t) == VECTOR_SIZE * 8, "");
401 // --------------------------------------------------------------------------//
402 // Alignof
404 #define VECTOR_ALIGN 8
406 _Static_assert(__alignof__(fixed_int8mf8_t) == (sizeof(fixed_int8mf8_t) < VECTOR_ALIGN ? sizeof(fixed_int8mf8_t) : VECTOR_ALIGN), "");
408 _Static_assert(__alignof__(fixed_uint8mf8_t) == (sizeof(fixed_uint8mf8_t) < VECTOR_ALIGN ? sizeof(fixed_int8mf8_t) : VECTOR_ALIGN), "");
410 _Static_assert(__alignof__(fixed_int8mf4_t) == (sizeof(fixed_int8mf4_t) < VECTOR_ALIGN ? sizeof(fixed_int8mf4_t) : VECTOR_ALIGN), "");
411 _Static_assert(__alignof__(fixed_int16mf4_t) == (sizeof(fixed_int16mf4_t) < VECTOR_ALIGN ? sizeof(fixed_int16mf4_t) : VECTOR_ALIGN), "");
413 _Static_assert(__alignof__(fixed_uint8mf4_t) == (sizeof(fixed_uint8mf4_t) < VECTOR_ALIGN ? sizeof(fixed_uint8mf4_t) : VECTOR_ALIGN), "");
414 _Static_assert(__alignof__(fixed_uint16mf4_t) == (sizeof(fixed_uint16mf4_t) < VECTOR_ALIGN ? sizeof(fixed_uint16mf4_t) : VECTOR_ALIGN), "");
416 _Static_assert(__alignof__(fixed_int8mf2_t) == (sizeof(fixed_int8mf2_t) < VECTOR_ALIGN ? sizeof(fixed_int8mf2_t) : VECTOR_ALIGN), "");
417 _Static_assert(__alignof__(fixed_int16mf2_t) == (sizeof(fixed_int16mf2_t) < VECTOR_ALIGN ? sizeof(fixed_int16mf2_t) : VECTOR_ALIGN), "");
418 _Static_assert(__alignof__(fixed_int32mf2_t) == (sizeof(fixed_int32mf2_t) < VECTOR_ALIGN ? sizeof(fixed_int32mf2_t) : VECTOR_ALIGN), "");
420 _Static_assert(__alignof__(fixed_uint8mf2_t) == (sizeof(fixed_uint8mf2_t) < VECTOR_ALIGN ? sizeof(fixed_uint8mf2_t) : VECTOR_ALIGN), "");
421 _Static_assert(__alignof__(fixed_uint16mf2_t) == (sizeof(fixed_uint16mf2_t) < VECTOR_ALIGN ? sizeof(fixed_uint16mf2_t) : VECTOR_ALIGN), "");
422 _Static_assert(__alignof__(fixed_uint32mf2_t) == (sizeof(fixed_uint32mf2_t) < VECTOR_ALIGN ? sizeof(fixed_uint32mf2_t) : VECTOR_ALIGN), "");
424 _Static_assert(__alignof__(fixed_float32mf2_t) == (sizeof(fixed_float32mf2_t) < VECTOR_ALIGN ? sizeof(fixed_float32mf2_t) : VECTOR_ALIGN), "");
426 _Static_assert(__alignof__(fixed_int8m1_t) == VECTOR_ALIGN, "");
427 _Static_assert(__alignof__(fixed_int16m1_t) == VECTOR_ALIGN, "");
428 _Static_assert(__alignof__(fixed_int32m1_t) == VECTOR_ALIGN, "");
429 _Static_assert(__alignof__(fixed_int64m1_t) == VECTOR_ALIGN, "");
431 _Static_assert(__alignof__(fixed_uint8m1_t) == VECTOR_ALIGN, "");
432 _Static_assert(__alignof__(fixed_uint16m1_t) == VECTOR_ALIGN, "");
433 _Static_assert(__alignof__(fixed_uint32m1_t) == VECTOR_ALIGN, "");
434 _Static_assert(__alignof__(fixed_uint64m1_t) == VECTOR_ALIGN, "");
436 _Static_assert(__alignof__(fixed_float32m1_t) == VECTOR_ALIGN, "");
437 _Static_assert(__alignof__(fixed_float64m1_t) == VECTOR_ALIGN, "");
439 _Static_assert(__alignof__(fixed_int8m2_t) == VECTOR_ALIGN, "");
440 _Static_assert(__alignof__(fixed_int16m2_t) == VECTOR_ALIGN, "");
441 _Static_assert(__alignof__(fixed_int32m2_t) == VECTOR_ALIGN, "");
442 _Static_assert(__alignof__(fixed_int64m2_t) == VECTOR_ALIGN, "");
444 _Static_assert(__alignof__(fixed_uint8m2_t) == VECTOR_ALIGN, "");
445 _Static_assert(__alignof__(fixed_uint16m2_t) == VECTOR_ALIGN, "");
446 _Static_assert(__alignof__(fixed_uint32m2_t) == VECTOR_ALIGN, "");
447 _Static_assert(__alignof__(fixed_uint64m2_t) == VECTOR_ALIGN, "");
449 _Static_assert(__alignof__(fixed_float32m2_t) == VECTOR_ALIGN, "");
450 _Static_assert(__alignof__(fixed_float64m2_t) == VECTOR_ALIGN, "");
452 _Static_assert(__alignof__(fixed_int8m4_t) == VECTOR_ALIGN, "");
453 _Static_assert(__alignof__(fixed_int16m4_t) == VECTOR_ALIGN, "");
454 _Static_assert(__alignof__(fixed_int32m4_t) == VECTOR_ALIGN, "");
455 _Static_assert(__alignof__(fixed_int64m4_t) == VECTOR_ALIGN, "");
457 _Static_assert(__alignof__(fixed_uint8m4_t) == VECTOR_ALIGN, "");
458 _Static_assert(__alignof__(fixed_uint16m4_t) == VECTOR_ALIGN, "");
459 _Static_assert(__alignof__(fixed_uint32m4_t) == VECTOR_ALIGN, "");
460 _Static_assert(__alignof__(fixed_uint64m4_t) == VECTOR_ALIGN, "");
462 _Static_assert(__alignof__(fixed_float32m4_t) == VECTOR_ALIGN, "");
463 _Static_assert(__alignof__(fixed_float64m4_t) == VECTOR_ALIGN, "");
465 _Static_assert(__alignof__(fixed_int8m8_t) == VECTOR_ALIGN, "");
466 _Static_assert(__alignof__(fixed_int16m8_t) == VECTOR_ALIGN, "");
467 _Static_assert(__alignof__(fixed_int32m8_t) == VECTOR_ALIGN, "");
468 _Static_assert(__alignof__(fixed_int64m8_t) == VECTOR_ALIGN, "");
470 _Static_assert(__alignof__(fixed_uint8m8_t) == VECTOR_ALIGN, "");
471 _Static_assert(__alignof__(fixed_uint16m8_t) == VECTOR_ALIGN, "");
472 _Static_assert(__alignof__(fixed_uint32m8_t) == VECTOR_ALIGN, "");
473 _Static_assert(__alignof__(fixed_uint64m8_t) == VECTOR_ALIGN, "");
475 _Static_assert(__alignof__(fixed_float32m8_t) == VECTOR_ALIGN, "");
476 _Static_assert(__alignof__(fixed_float64m8_t) == VECTOR_ALIGN, "");
478 // --------------------------------------------------------------------------//
479 // Structs
481 struct struct_int64 { fixed_int64m1_t x, y[5]; };
482 struct struct_float64 { fixed_float64m1_t x, y[5]; };
484 struct struct_int64m2 { fixed_int64m2_t x, y[5]; };
485 struct struct_float64m2 { fixed_float64m2_t x, y[5]; };
487 struct struct_int64m4 { fixed_int64m4_t x, y[5]; };
488 struct struct_float64m4 { fixed_float64m4_t x, y[5]; };
490 struct struct_int64m8 { fixed_int64m8_t x, y[5]; };
491 struct struct_float64m8 { fixed_float64m8_t x, y[5]; };
493 // --------------------------------------------------------------------------//
494 // Unions
495 union union_int64 { fixed_int64m1_t x, y[5]; };
496 union union_float64 { fixed_float64m1_t x, y[5]; };
498 union union_int64m2 { fixed_int64m2_t x, y[5]; };
499 union union_float64m2 { fixed_float64m2_t x, y[5]; };
501 union union_int64m4 { fixed_int64m4_t x, y[5]; };
502 union union_float64m4 { fixed_float64m4_t x, y[5]; };
504 union union_int64m8 { fixed_int64m8_t x, y[5]; };
505 union union_float64m8 { fixed_float64m8_t x, y[5]; };
507 // --------------------------------------------------------------------------//
508 // Implicit casts
510 #define TEST_CAST_COMMON(TYPE) \
511 v##TYPE##_t to_v##TYPE##_t_from_fixed(fixed_##TYPE##_t x) { return x; } \
512 fixed_##TYPE##_t from_##TYPE##_t_to_fixed(v##TYPE##_t x) { return x; }
514 #define TEST_CAST_GNU(PREFIX, TYPE) \
515 gnu_##TYPE##_t to_gnu_##TYPE##_t_from_##PREFIX##TYPE##_t(PREFIX##TYPE##_t x) { return x; } \
516 PREFIX##TYPE##_t from_gnu_##TYPE##_t_to_##PREFIX##TYPE##_t(gnu_##TYPE##_t x) { return x; }
518 #define TEST_CAST_VECTOR(TYPE) \
519 TEST_CAST_COMMON(TYPE) \
520 TEST_CAST_GNU(v, TYPE) \
521 TEST_CAST_GNU(fixed_, TYPE)
523 TEST_CAST_VECTOR(int8mf8)
524 TEST_CAST_VECTOR(uint8mf8)
526 TEST_CAST_VECTOR(int8mf4)
527 TEST_CAST_VECTOR(int16mf4)
528 TEST_CAST_VECTOR(uint8mf4)
529 TEST_CAST_VECTOR(uint16mf4)
531 TEST_CAST_VECTOR(int8mf2)
532 TEST_CAST_VECTOR(int16mf2)
533 TEST_CAST_VECTOR(int32mf2)
534 TEST_CAST_VECTOR(uint8mf2)
535 TEST_CAST_VECTOR(uint16mf2)
536 TEST_CAST_VECTOR(uint32mf2)
537 TEST_CAST_VECTOR(float32mf2)
539 TEST_CAST_VECTOR(int8m1)
540 TEST_CAST_VECTOR(int16m1)
541 TEST_CAST_VECTOR(int32m1)
542 TEST_CAST_VECTOR(int64m1)
543 TEST_CAST_VECTOR(uint8m1)
544 TEST_CAST_VECTOR(uint16m1)
545 TEST_CAST_VECTOR(uint32m1)
546 TEST_CAST_VECTOR(uint64m1)
547 TEST_CAST_VECTOR(float32m1)
548 TEST_CAST_VECTOR(float64m1)
550 TEST_CAST_VECTOR(int8m2)
551 TEST_CAST_VECTOR(int16m2)
552 TEST_CAST_VECTOR(int32m2)
553 TEST_CAST_VECTOR(int64m2)
554 TEST_CAST_VECTOR(uint8m2)
555 TEST_CAST_VECTOR(uint16m2)
556 TEST_CAST_VECTOR(uint32m2)
557 TEST_CAST_VECTOR(uint64m2)
558 TEST_CAST_VECTOR(float32m2)
559 TEST_CAST_VECTOR(float64m2)
561 TEST_CAST_VECTOR(int8m4)
562 TEST_CAST_VECTOR(int16m4)
563 TEST_CAST_VECTOR(int32m4)
564 TEST_CAST_VECTOR(int64m4)
565 TEST_CAST_VECTOR(uint8m4)
566 TEST_CAST_VECTOR(uint16m4)
567 TEST_CAST_VECTOR(uint32m4)
568 TEST_CAST_VECTOR(uint64m4)
569 TEST_CAST_VECTOR(float32m4)
570 TEST_CAST_VECTOR(float64m4)
572 TEST_CAST_VECTOR(int8m8)
573 TEST_CAST_VECTOR(int16m8)
574 TEST_CAST_VECTOR(int32m8)
575 TEST_CAST_VECTOR(int64m8)
576 TEST_CAST_VECTOR(uint8m8)
577 TEST_CAST_VECTOR(uint16m8)
578 TEST_CAST_VECTOR(uint32m8)
579 TEST_CAST_VECTOR(uint64m8)
580 TEST_CAST_VECTOR(float32m8)
581 TEST_CAST_VECTOR(float64m8)
583 // --------------------------------------------------------------------------//
584 // Test the scalable and fixed-length types can be used interchangeably
586 vint32m1_t __attribute__((overloadable)) vfunc(vint32m1_t op1, vint32m1_t op2);
587 vfloat64m1_t __attribute__((overloadable)) vfunc(vfloat64m1_t op1, vfloat64m1_t op2);
589 vint32m2_t __attribute__((overloadable)) vfunc(vint32m2_t op1, vint32m2_t op2);
590 vfloat64m2_t __attribute__((overloadable)) vfunc(vfloat64m2_t op1, vfloat64m2_t op2);
592 vint32m4_t __attribute__((overloadable)) vfunc(vint32m4_t op1, vint32m4_t op2);
593 vfloat64m4_t __attribute__((overloadable)) vfunc(vfloat64m4_t op1, vfloat64m4_t op2);
595 vint32m8_t __attribute__((overloadable)) vfunc(vint32m8_t op1, vint32m8_t op2);
596 vfloat64m8_t __attribute__((overloadable)) vfunc(vfloat64m8_t op1, vfloat64m8_t op2);
598 #define TEST_CALL(TYPE) \
599 fixed_##TYPE##_t \
600 call_##TYPE##_ff(fixed_##TYPE##_t op1, fixed_##TYPE##_t op2) { \
601 return vfunc(op1, op2); \
603 fixed_##TYPE##_t \
604 call_##TYPE##_fs(fixed_##TYPE##_t op1, v##TYPE##_t op2) { \
605 return vfunc(op1, op2); \
607 fixed_##TYPE##_t \
608 call_##TYPE##_sf(v##TYPE##_t op1, fixed_##TYPE##_t op2) { \
609 return vfunc(op1, op2); \
612 TEST_CALL(int32m1)
613 TEST_CALL(float64m1)
615 TEST_CALL(int32m2)
616 TEST_CALL(float64m2)
618 TEST_CALL(int32m4)
619 TEST_CALL(float64m4)
621 TEST_CALL(int32m8)
622 TEST_CALL(float64m8)
624 // --------------------------------------------------------------------------//
625 // Vector initialization
627 #if __riscv_v_fixed_vlen == 256
629 typedef vint32m1_t int32x8 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
630 typedef vfloat64m1_t float64x4 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
632 typedef vint32m2_t int32x16 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));
633 typedef vfloat64m2_t float64x8 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));
635 typedef vint32m4_t int32x32 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));
636 typedef vfloat64m4_t float64x16 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));
638 typedef vint32m8_t int32x64 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));
639 typedef vfloat64m8_t float64x32 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));
641 int32x8 foo = {1, 2, 3, 4, 5, 6, 7, 8};
642 int32x8 foo2 = {1, 2, 3, 4, 5, 6, 7, 8, 9}; // expected-warning{{excess elements in vector initializer}}
644 float64x4 bar = {1.0, 2.0, 3.0, 4.0};
645 float64x4 bar2 = {1.0, 2.0, 3.0, 4.0, 5.0}; // expected-warning{{excess elements in vector initializer}}
647 int32x16 foom2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
648 int32x16 foo2m2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; // expected-warning{{excess elements in vector initializer}}
650 float64x8 barm2 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0};
651 float64x8 bar2m2 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; // expected-warning{{excess elements in vector initializer}}
653 int32x32 foom4 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
654 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
655 32};
656 int32x32 foo2m4 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
657 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
658 32, 33}; // expected-warning{{excess elements in vector initializer}}
660 float64x16 barm4 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0,
661 12.0, 13.0, 14.0, 15.0, 16.0};
662 float64x16 bar2m4 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0,
663 12.0, 13.0, 14.0, 15.0, 16.0, 17.0}; // expected-warning{{excess elements in vector initializer}}
665 int32x64 foom8 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
666 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
667 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
668 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
669 64};
670 int32x64 foo2m8 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
671 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
672 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
673 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
674 63, 64, 65}; // expected-warning{{excess elements in vector initializer}}
676 float64x32 barm8 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0,
677 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0,
678 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0,
679 32.0};
680 float64x32 bar2m8 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0,
681 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0,
682 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0,
683 32.0, 33.0}; // expected-warning{{excess elements in vector initializer}}
684 #endif
686 // --------------------------------------------------------------------------//
687 // Vector ops
689 #define TEST_BINARY(TYPE, NAME, OP) \
690 TYPE NAME##_##TYPE(TYPE op1, TYPE op2) { \
691 return op1 OP op2; \
693 TYPE compound##NAME##_##TYPE(TYPE op1, TYPE op2) { \
694 op1 OP##= op2; \
695 return op1; \
698 #define TEST_COMPARISON(TYPE, NAME, OP) \
699 TYPE NAME##_##TYPE(TYPE op1, TYPE op2) { \
700 return op1 OP op2; \
703 #define TEST_UNARY(TYPE, NAME, OP) \
704 TYPE NAME##_##TYPE(TYPE op1) { \
705 return OP op1; \
708 #define TEST_OPS(TYPE) \
709 TEST_BINARY(TYPE, add, +) \
710 TEST_BINARY(TYPE, sub, -) \
711 TEST_BINARY(TYPE, mul, *) \
712 TEST_BINARY(TYPE, div, /) \
713 TEST_COMPARISON(TYPE, eq, ==) \
714 TEST_COMPARISON(TYPE, ne, !=) \
715 TEST_COMPARISON(TYPE, lt, <) \
716 TEST_COMPARISON(TYPE, gt, >) \
717 TEST_COMPARISON(TYPE, lte, <=) \
718 TEST_COMPARISON(TYPE, gte, >=) \
719 TEST_UNARY(TYPE, nop, +) \
720 TEST_UNARY(TYPE, neg, -)
722 #define TEST_INT_OPS(TYPE) \
723 TEST_OPS(TYPE) \
724 TEST_BINARY(TYPE, mod, %) \
725 TEST_BINARY(TYPE, and, &) \
726 TEST_BINARY(TYPE, or, |) \
727 TEST_BINARY(TYPE, xor, ^) \
728 TEST_BINARY(TYPE, shl, <<) \
729 TEST_BINARY(TYPE, shr, <<) \
730 TEST_UNARY(TYPE, not, ~)
732 TEST_INT_OPS(fixed_int8mf8_t)
733 TEST_INT_OPS(fixed_uint8mf8_t)
735 TEST_INT_OPS(fixed_int8mf4_t)
736 TEST_INT_OPS(fixed_int16mf4_t)
737 TEST_INT_OPS(fixed_uint8mf4_t)
738 TEST_INT_OPS(fixed_uint16mf4_t)
740 TEST_INT_OPS(fixed_int8mf2_t)
741 TEST_INT_OPS(fixed_int16mf2_t)
742 TEST_INT_OPS(fixed_int32mf2_t)
743 TEST_INT_OPS(fixed_uint8mf2_t)
744 TEST_INT_OPS(fixed_uint16mf2_t)
745 TEST_INT_OPS(fixed_uint32mf2_t)
747 TEST_OPS(fixed_float32mf2_t)
749 TEST_INT_OPS(fixed_int8m1_t)
750 TEST_INT_OPS(fixed_int16m1_t)
751 TEST_INT_OPS(fixed_int32m1_t)
752 TEST_INT_OPS(fixed_int64m1_t)
753 TEST_INT_OPS(fixed_uint8m1_t)
754 TEST_INT_OPS(fixed_uint16m1_t)
755 TEST_INT_OPS(fixed_uint32m1_t)
756 TEST_INT_OPS(fixed_uint64m1_t)
758 TEST_OPS(fixed_float32m1_t)
759 TEST_OPS(fixed_float64m1_t)
761 TEST_INT_OPS(fixed_int8m2_t)
762 TEST_INT_OPS(fixed_int16m2_t)
763 TEST_INT_OPS(fixed_int32m2_t)
764 TEST_INT_OPS(fixed_int64m2_t)
765 TEST_INT_OPS(fixed_uint8m2_t)
766 TEST_INT_OPS(fixed_uint16m2_t)
767 TEST_INT_OPS(fixed_uint32m2_t)
768 TEST_INT_OPS(fixed_uint64m2_t)
770 TEST_OPS(fixed_float32m2_t)
771 TEST_OPS(fixed_float64m2_t)
773 TEST_INT_OPS(fixed_int8m4_t)
774 TEST_INT_OPS(fixed_int16m4_t)
775 TEST_INT_OPS(fixed_int32m4_t)
776 TEST_INT_OPS(fixed_int64m4_t)
777 TEST_INT_OPS(fixed_uint8m4_t)
778 TEST_INT_OPS(fixed_uint16m4_t)
779 TEST_INT_OPS(fixed_uint32m4_t)
780 TEST_INT_OPS(fixed_uint64m4_t)
782 TEST_OPS(fixed_float32m4_t)
783 TEST_OPS(fixed_float64m4_t)
785 TEST_INT_OPS(fixed_int8m8_t)
786 TEST_INT_OPS(fixed_int16m8_t)
787 TEST_INT_OPS(fixed_int32m8_t)
788 TEST_INT_OPS(fixed_int64m8_t)
789 TEST_INT_OPS(fixed_uint8m8_t)
790 TEST_INT_OPS(fixed_uint16m8_t)
791 TEST_INT_OPS(fixed_uint32m8_t)
792 TEST_INT_OPS(fixed_uint64m8_t)
794 TEST_OPS(fixed_float32m8_t)
795 TEST_OPS(fixed_float64m8_t)