Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / builtins-elementwise-math.c
blobe7b36285fa7dcfdc920514a7932d732fd36c8fcd
1 // RUN: %clang_cc1 -std=c99 %s -pedantic -verify -triple=x86_64-apple-darwin9
3 typedef double double2 __attribute__((ext_vector_type(2)));
4 typedef double double4 __attribute__((ext_vector_type(4)));
5 typedef float float2 __attribute__((ext_vector_type(2)));
6 typedef float float4 __attribute__((ext_vector_type(4)));
8 typedef int int2 __attribute__((ext_vector_type(2)));
9 typedef int int3 __attribute__((ext_vector_type(3)));
10 typedef unsigned unsigned3 __attribute__((ext_vector_type(3)));
11 typedef unsigned unsigned4 __attribute__((ext_vector_type(4)));
13 struct Foo {
14 char *p;
17 __attribute__((address_space(1))) int int_as_one;
18 typedef int bar;
19 bar b;
21 __attribute__((address_space(1))) float float_as_one;
22 typedef float waffle;
23 waffle waf;
26 void test_builtin_elementwise_abs(int i, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
27 struct Foo s = __builtin_elementwise_abs(i);
28 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
30 i = __builtin_elementwise_abs();
31 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
33 i = __builtin_elementwise_abs(i, i);
34 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
36 i = __builtin_elementwise_abs(v);
37 // expected-error@-1 {{assigning to 'int' from incompatible type 'float4' (vector of 4 'float' values)}}
39 u = __builtin_elementwise_abs(u);
40 // expected-error@-1 {{1st argument must be a signed integer or floating point type (was 'unsigned int')}}
42 uv = __builtin_elementwise_abs(uv);
43 // expected-error@-1 {{1st argument must be a signed integer or floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
46 void test_builtin_elementwise_add_sat(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) {
47 i = __builtin_elementwise_add_sat(p, d);
48 // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}}
50 struct Foo foo = __builtin_elementwise_add_sat(i, i);
51 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
53 i = __builtin_elementwise_add_sat(i);
54 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
56 i = __builtin_elementwise_add_sat();
57 // expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
59 i = __builtin_elementwise_add_sat(i, i, i);
60 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
62 i = __builtin_elementwise_add_sat(v, iv);
63 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}
65 i = __builtin_elementwise_add_sat(uv, iv);
66 // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}
68 v = __builtin_elementwise_add_sat(v, v);
69 // expected-error@-1 {{1st argument must be a vector of integers (was 'float4' (vector of 4 'float' values))}}
71 s = __builtin_elementwise_add_sat(i, s);
73 enum e { one,
74 two };
75 i = __builtin_elementwise_add_sat(one, two);
77 enum f { three };
78 enum f x = __builtin_elementwise_add_sat(one, three);
80 _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}}
81 ext = __builtin_elementwise_add_sat(ext, ext);
83 const int ci;
84 i = __builtin_elementwise_add_sat(ci, i);
85 i = __builtin_elementwise_add_sat(i, ci);
86 i = __builtin_elementwise_add_sat(ci, ci);
88 i = __builtin_elementwise_add_sat(i, int_as_one); // ok (attributes don't match)?
89 i = __builtin_elementwise_add_sat(i, b); // ok (sugar doesn't match)?
91 int A[10];
92 A = __builtin_elementwise_add_sat(A, A);
93 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}}
95 int(ii);
96 int j;
97 j = __builtin_elementwise_add_sat(i, j);
99 _Complex float c1, c2;
100 c1 = __builtin_elementwise_add_sat(c1, c2);
101 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
104 void test_builtin_elementwise_sub_sat(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) {
105 i = __builtin_elementwise_sub_sat(p, d);
106 // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}}
108 struct Foo foo = __builtin_elementwise_sub_sat(i, i);
109 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
111 i = __builtin_elementwise_sub_sat(i);
112 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
114 i = __builtin_elementwise_sub_sat();
115 // expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
117 i = __builtin_elementwise_sub_sat(i, i, i);
118 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
120 i = __builtin_elementwise_sub_sat(v, iv);
121 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}
123 i = __builtin_elementwise_sub_sat(uv, iv);
124 // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}
126 v = __builtin_elementwise_sub_sat(v, v);
127 // expected-error@-1 {{1st argument must be a vector of integers (was 'float4' (vector of 4 'float' values))}}
129 s = __builtin_elementwise_sub_sat(i, s);
131 enum e { one,
132 two };
133 i = __builtin_elementwise_sub_sat(one, two);
135 enum f { three };
136 enum f x = __builtin_elementwise_sub_sat(one, three);
138 _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}}
139 ext = __builtin_elementwise_sub_sat(ext, ext);
141 const int ci;
142 i = __builtin_elementwise_sub_sat(ci, i);
143 i = __builtin_elementwise_sub_sat(i, ci);
144 i = __builtin_elementwise_sub_sat(ci, ci);
146 i = __builtin_elementwise_sub_sat(i, int_as_one); // ok (attributes don't match)?
147 i = __builtin_elementwise_sub_sat(i, b); // ok (sugar doesn't match)?
149 int A[10];
150 A = __builtin_elementwise_sub_sat(A, A);
151 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}}
153 int(ii);
154 int j;
155 j = __builtin_elementwise_sub_sat(i, j);
157 _Complex float c1, c2;
158 c1 = __builtin_elementwise_sub_sat(c1, c2);
159 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
162 void test_builtin_elementwise_max(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) {
163 i = __builtin_elementwise_max(p, d);
164 // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}}
166 struct Foo foo = __builtin_elementwise_max(i, i);
167 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
169 i = __builtin_elementwise_max(i);
170 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
172 i = __builtin_elementwise_max();
173 // expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
175 i = __builtin_elementwise_max(i, i, i);
176 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
178 i = __builtin_elementwise_max(v, iv);
179 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}
181 i = __builtin_elementwise_max(uv, iv);
182 // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}
184 s = __builtin_elementwise_max(i, s);
186 enum e { one,
187 two };
188 i = __builtin_elementwise_max(one, two);
190 enum f { three };
191 enum f x = __builtin_elementwise_max(one, three);
193 _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}}
194 ext = __builtin_elementwise_max(ext, ext);
196 const int ci;
197 i = __builtin_elementwise_max(ci, i);
198 i = __builtin_elementwise_max(i, ci);
199 i = __builtin_elementwise_max(ci, ci);
201 i = __builtin_elementwise_max(i, int_as_one); // ok (attributes don't match)?
202 i = __builtin_elementwise_max(i, b); // ok (sugar doesn't match)?
204 int A[10];
205 A = __builtin_elementwise_max(A, A);
206 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}}
208 int(ii);
209 int j;
210 j = __builtin_elementwise_max(i, j);
212 _Complex float c1, c2;
213 c1 = __builtin_elementwise_max(c1, c2);
214 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
217 void test_builtin_elementwise_min(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) {
218 i = __builtin_elementwise_min(p, d);
219 // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}}
221 struct Foo foo = __builtin_elementwise_min(i, i);
222 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
224 i = __builtin_elementwise_min(i);
225 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
227 i = __builtin_elementwise_min();
228 // expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
230 i = __builtin_elementwise_min(i, i, i);
231 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
233 i = __builtin_elementwise_min(v, iv);
234 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}
236 i = __builtin_elementwise_min(uv, iv);
237 // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}
239 s = __builtin_elementwise_min(i, s);
241 enum e { one,
242 two };
243 i = __builtin_elementwise_min(one, two);
245 enum f { three };
246 enum f x = __builtin_elementwise_min(one, three);
248 _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}}
249 ext = __builtin_elementwise_min(ext, ext);
251 const int ci;
252 i = __builtin_elementwise_min(ci, i);
253 i = __builtin_elementwise_min(i, ci);
254 i = __builtin_elementwise_min(ci, ci);
256 i = __builtin_elementwise_min(i, int_as_one); // ok (attributes don't match)?
257 i = __builtin_elementwise_min(i, b); // ok (sugar doesn't match)?
259 int A[10];
260 A = __builtin_elementwise_min(A, A);
261 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}}
263 int(ii);
264 int j;
265 j = __builtin_elementwise_min(i, j);
267 _Complex float c1, c2;
268 c1 = __builtin_elementwise_min(c1, c2);
269 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
272 void test_builtin_elementwise_bitreverse(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
274 struct Foo s = __builtin_elementwise_ceil(f);
275 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
277 i = __builtin_elementwise_bitreverse();
278 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
280 i = __builtin_elementwise_bitreverse(f);
281 // expected-error@-1 {{1st argument must be a vector of integers (was 'float')}}
283 i = __builtin_elementwise_bitreverse(f, f);
284 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
286 u = __builtin_elementwise_bitreverse(d);
287 // expected-error@-1 {{1st argument must be a vector of integers (was 'double')}}
289 v = __builtin_elementwise_bitreverse(v);
290 // expected-error@-1 {{1st argument must be a vector of integers (was 'float4' (vector of 4 'float' values))}}
293 void test_builtin_elementwise_ceil(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
295 struct Foo s = __builtin_elementwise_ceil(f);
296 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
298 i = __builtin_elementwise_ceil();
299 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
301 i = __builtin_elementwise_ceil(i);
302 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
304 i = __builtin_elementwise_ceil(f, f);
305 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
307 u = __builtin_elementwise_ceil(u);
308 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
310 uv = __builtin_elementwise_ceil(uv);
311 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
314 void test_builtin_elementwise_cos(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
316 struct Foo s = __builtin_elementwise_cos(f);
317 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
319 i = __builtin_elementwise_cos();
320 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
322 i = __builtin_elementwise_cos(i);
323 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
325 i = __builtin_elementwise_cos(f, f);
326 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
328 u = __builtin_elementwise_cos(u);
329 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
331 uv = __builtin_elementwise_cos(uv);
332 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
335 void test_builtin_elementwise_exp(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
337 struct Foo s = __builtin_elementwise_exp(f);
338 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
340 i = __builtin_elementwise_exp();
341 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
343 i = __builtin_elementwise_exp(i);
344 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
346 i = __builtin_elementwise_exp(f, f);
347 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
349 u = __builtin_elementwise_exp(u);
350 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
352 uv = __builtin_elementwise_exp(uv);
353 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
356 void test_builtin_elementwise_exp2(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
358 struct Foo s = __builtin_elementwise_exp2(f);
359 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
361 i = __builtin_elementwise_exp2();
362 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
364 i = __builtin_elementwise_exp2(i);
365 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
367 i = __builtin_elementwise_exp2(f, f);
368 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
370 u = __builtin_elementwise_exp2(u);
371 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
373 uv = __builtin_elementwise_exp2(uv);
374 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
378 void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
380 struct Foo s = __builtin_elementwise_floor(f);
381 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
383 i = __builtin_elementwise_floor();
384 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
386 i = __builtin_elementwise_floor(i);
387 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
389 i = __builtin_elementwise_floor(f, f);
390 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
392 u = __builtin_elementwise_floor(u);
393 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
395 uv = __builtin_elementwise_floor(uv);
396 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
399 void test_builtin_elementwise_log(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
401 struct Foo s = __builtin_elementwise_log(f);
402 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
404 i = __builtin_elementwise_log();
405 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
407 i = __builtin_elementwise_log(i);
408 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
410 i = __builtin_elementwise_log(f, f);
411 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
413 u = __builtin_elementwise_log(u);
414 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
416 uv = __builtin_elementwise_log(uv);
417 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
420 void test_builtin_elementwise_log10(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
422 struct Foo s = __builtin_elementwise_log10(f);
423 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
425 i = __builtin_elementwise_log10();
426 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
428 i = __builtin_elementwise_log10(i);
429 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
431 i = __builtin_elementwise_log10(f, f);
432 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
434 u = __builtin_elementwise_log10(u);
435 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
437 uv = __builtin_elementwise_log10(uv);
438 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
441 void test_builtin_elementwise_log2(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
443 struct Foo s = __builtin_elementwise_log2(f);
444 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
446 i = __builtin_elementwise_log2();
447 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
449 i = __builtin_elementwise_log2(i);
450 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
452 i = __builtin_elementwise_log2(f, f);
453 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
455 u = __builtin_elementwise_log2(u);
456 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
458 uv = __builtin_elementwise_log2(uv);
459 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
462 void test_builtin_elementwise_pow(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) {
463 i = __builtin_elementwise_pow(p, d);
464 // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}}
466 struct Foo foo = __builtin_elementwise_pow(i, i);
467 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
469 i = __builtin_elementwise_pow(i);
470 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
472 i = __builtin_elementwise_pow();
473 // expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
475 i = __builtin_elementwise_pow(i, i, i);
476 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
478 i = __builtin_elementwise_pow(v, iv);
479 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}
481 i = __builtin_elementwise_pow(uv, iv);
482 // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}
487 void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
489 struct Foo s = __builtin_elementwise_roundeven(f);
490 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
492 i = __builtin_elementwise_roundeven();
493 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
495 i = __builtin_elementwise_roundeven(i);
496 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
498 i = __builtin_elementwise_roundeven(f, f);
499 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
501 u = __builtin_elementwise_roundeven(u);
502 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
504 uv = __builtin_elementwise_roundeven(uv);
505 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
508 void test_builtin_elementwise_round(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
509 struct Foo s = __builtin_elementwise_round(f);
510 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
512 i = __builtin_elementwise_round();
513 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
515 i = __builtin_elementwise_round(i);
516 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
518 i = __builtin_elementwise_round(f, f);
519 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
521 u = __builtin_elementwise_round(u);
522 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
524 uv = __builtin_elementwise_round(uv);
525 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
527 // FIXME: Error should not mention integer
528 _Complex float c1, c2;
529 c1 = __builtin_elementwise_round(c1);
530 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
533 void test_builtin_elementwise_rint(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
534 struct Foo s = __builtin_elementwise_rint(f);
535 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
537 i = __builtin_elementwise_rint();
538 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
540 i = __builtin_elementwise_rint(i);
541 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
543 i = __builtin_elementwise_rint(f, f);
544 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
546 u = __builtin_elementwise_rint(u);
547 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
549 uv = __builtin_elementwise_rint(uv);
550 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
552 // FIXME: Error should not mention integer
553 _Complex float c1, c2;
554 c1 = __builtin_elementwise_rint(c1);
555 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
558 void test_builtin_elementwise_nearbyint(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
559 struct Foo s = __builtin_elementwise_nearbyint(f);
560 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
562 i = __builtin_elementwise_nearbyint();
563 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
565 i = __builtin_elementwise_nearbyint(i);
566 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
568 i = __builtin_elementwise_nearbyint(f, f);
569 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
571 u = __builtin_elementwise_nearbyint(u);
572 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
574 uv = __builtin_elementwise_nearbyint(uv);
575 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
577 // FIXME: Error should not mention integer
578 _Complex float c1, c2;
579 c1 = __builtin_elementwise_nearbyint(c1);
580 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
583 void test_builtin_elementwise_sin(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
585 struct Foo s = __builtin_elementwise_sin(f);
586 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
588 i = __builtin_elementwise_sin();
589 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
591 i = __builtin_elementwise_sin(i);
592 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
594 i = __builtin_elementwise_sin(f, f);
595 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
597 u = __builtin_elementwise_sin(u);
598 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
600 uv = __builtin_elementwise_sin(uv);
601 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
604 void test_builtin_elementwise_sqrt(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
606 struct Foo s = __builtin_elementwise_sqrt(f);
607 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
609 i = __builtin_elementwise_sqrt();
610 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
612 i = __builtin_elementwise_sqrt(i);
613 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
615 i = __builtin_elementwise_sqrt(f, f);
616 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
618 u = __builtin_elementwise_sqrt(u);
619 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
621 uv = __builtin_elementwise_sqrt(uv);
622 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
625 void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
627 struct Foo s = __builtin_elementwise_trunc(f);
628 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
630 i = __builtin_elementwise_trunc();
631 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
633 i = __builtin_elementwise_trunc(i);
634 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
636 i = __builtin_elementwise_trunc(f, f);
637 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
639 u = __builtin_elementwise_trunc(u);
640 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
642 uv = __builtin_elementwise_trunc(uv);
643 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
646 void test_builtin_elementwise_canonicalize(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
648 struct Foo s = __builtin_elementwise_canonicalize(f);
649 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
651 i = __builtin_elementwise_canonicalize();
652 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
654 i = __builtin_elementwise_canonicalize(i);
655 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
657 i = __builtin_elementwise_canonicalize(f, f);
658 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
660 u = __builtin_elementwise_canonicalize(u);
661 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
663 uv = __builtin_elementwise_canonicalize(uv);
664 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
667 void test_builtin_elementwise_copysign(int i, short s, double d, float f, float4 v, int3 iv, unsigned3 uv, int *p) {
668 i = __builtin_elementwise_copysign(p, d);
669 // expected-error@-1 {{1st argument must be a floating point type (was 'int *')}}
671 i = __builtin_elementwise_copysign(i, i);
672 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
674 i = __builtin_elementwise_copysign(i);
675 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
677 i = __builtin_elementwise_copysign();
678 // expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
680 i = __builtin_elementwise_copysign(i, i, i);
681 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
683 i = __builtin_elementwise_copysign(v, iv);
684 // expected-error@-1 {{2nd argument must be a floating point type (was 'int3' (vector of 3 'int' values))}}
686 i = __builtin_elementwise_copysign(uv, iv);
687 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned3' (vector of 3 'unsigned int' values))}}
689 s = __builtin_elementwise_copysign(i, s);
690 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
692 f = __builtin_elementwise_copysign(f, i);
693 // expected-error@-1 {{2nd argument must be a floating point type (was 'int')}}
695 f = __builtin_elementwise_copysign(i, f);
696 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
698 enum e { one,
699 two };
700 i = __builtin_elementwise_copysign(one, two);
701 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
703 enum f { three };
704 enum f x = __builtin_elementwise_copysign(one, three);
705 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
707 _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}}
708 ext = __builtin_elementwise_copysign(ext, ext);
709 // expected-error@-1 {{1st argument must be a floating point type (was '_BitInt(32)')}}
711 const float cf32;
712 f = __builtin_elementwise_copysign(cf32, f);
713 f = __builtin_elementwise_copysign(f, cf32);
714 f = __builtin_elementwise_copysign(cf32, f);
716 f = __builtin_elementwise_copysign(f, float_as_one); // ok (attributes don't match)?
717 f = __builtin_elementwise_copysign(f, waf); // ok (sugar doesn't match)?
719 float A[10];
720 A = __builtin_elementwise_copysign(A, A);
721 // expected-error@-1 {{1st argument must be a floating point type (was 'float *')}}
723 float(ii);
724 float j;
725 j = __builtin_elementwise_copysign(f, j);
727 _Complex float c1, c2;
728 c1 = __builtin_elementwise_copysign(c1, c2);
729 // expected-error@-1 {{1st argument must be a floating point type (was '_Complex float')}}
731 double f64 = 0.0;
732 double tmp0 = __builtin_elementwise_copysign(f64, f);
733 // expected-error@-1 {{arguments are of different types ('double' vs 'float')}}
735 float tmp1 = __builtin_elementwise_copysign(f, f64);
736 //expected-error@-1 {{arguments are of different types ('float' vs 'double')}}
738 float4 v4f32 = 0.0f;
739 float4 tmp2 = __builtin_elementwise_copysign(v4f32, f);
740 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'float')}}
742 float tmp3 = __builtin_elementwise_copysign(f, v4f32);
743 // expected-error@-1 {{arguments are of different types ('float' vs 'float4' (vector of 4 'float' values))}}
745 float2 v2f32 = 0.0f;
746 double4 v4f64 = 0.0;
747 double4 tmp4 = __builtin_elementwise_copysign(v4f64, v4f32);
748 // expected-error@-1 {{arguments are of different types ('double4' (vector of 4 'double' values) vs 'float4' (vector of 4 'float' values))}}
750 float4 tmp6 = __builtin_elementwise_copysign(v4f32, v4f64);
751 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'double4' (vector of 4 'double' values))}}
753 float4 tmp7 = __builtin_elementwise_copysign(v4f32, v2f32);
754 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'float2' (vector of 2 'float' values))}}
756 float2 tmp8 = __builtin_elementwise_copysign(v2f32, v4f32);
757 // expected-error@-1 {{arguments are of different types ('float2' (vector of 2 'float' values) vs 'float4' (vector of 4 'float' values))}}
759 float2 tmp9 = __builtin_elementwise_copysign(v4f32, v4f32);
760 // expected-error@-1 {{initializing 'float2' (vector of 2 'float' values) with an expression of incompatible type 'float4' (vector of 4 'float' values)}}
763 void test_builtin_elementwise_fma(int i32, int2 v2i32, short i16,
764 double f64, double2 v2f64, double2 v3f64,
765 float f32, float2 v2f32, float v3f32, float4 v4f32,
766 const float4 c_v4f32,
767 int3 v3i32, int *ptr) {
769 f32 = __builtin_elementwise_fma();
770 // expected-error@-1 {{too few arguments to function call, expected 3, have 0}}
772 f32 = __builtin_elementwise_fma(f32);
773 // expected-error@-1 {{too few arguments to function call, expected 3, have 1}}
775 f32 = __builtin_elementwise_fma(f32, f32);
776 // expected-error@-1 {{too few arguments to function call, expected 3, have 2}}
778 f32 = __builtin_elementwise_fma(f32, f32, f32, f32);
779 // expected-error@-1 {{too many arguments to function call, expected 3, have 4}}
781 f32 = __builtin_elementwise_fma(f64, f32, f32);
782 // expected-error@-1 {{arguments are of different types ('double' vs 'float')}}
784 f32 = __builtin_elementwise_fma(f32, f64, f32);
785 // expected-error@-1 {{arguments are of different types ('float' vs 'double')}}
787 f32 = __builtin_elementwise_fma(f32, f32, f64);
788 // expected-error@-1 {{arguments are of different types ('float' vs 'double')}}
790 f32 = __builtin_elementwise_fma(f32, f32, f64);
791 // expected-error@-1 {{arguments are of different types ('float' vs 'double')}}
793 f64 = __builtin_elementwise_fma(f64, f32, f32);
794 // expected-error@-1 {{arguments are of different types ('double' vs 'float')}}
796 f64 = __builtin_elementwise_fma(f64, f64, f32);
797 // expected-error@-1 {{arguments are of different types ('double' vs 'float')}}
799 f64 = __builtin_elementwise_fma(f64, f32, f64);
800 // expected-error@-1 {{arguments are of different types ('double' vs 'float')}}
802 v2f64 = __builtin_elementwise_fma(v2f32, f64, f64);
803 // expected-error@-1 {{arguments are of different types ('float2' (vector of 2 'float' values) vs 'double'}}
805 v2f64 = __builtin_elementwise_fma(v2f32, v2f64, f64);
806 // expected-error@-1 {{arguments are of different types ('float2' (vector of 2 'float' values) vs 'double2' (vector of 2 'double' values)}}
808 v2f64 = __builtin_elementwise_fma(v2f32, f64, v2f64);
809 // expected-error@-1 {{arguments are of different types ('float2' (vector of 2 'float' values) vs 'double'}}
811 v2f64 = __builtin_elementwise_fma(f64, v2f32, v2f64);
812 // expected-error@-1 {{arguments are of different types ('double' vs 'float2' (vector of 2 'float' values)}}
814 v2f64 = __builtin_elementwise_fma(f64, v2f64, v2f64);
815 // expected-error@-1 {{arguments are of different types ('double' vs 'double2' (vector of 2 'double' values)}}
817 i32 = __builtin_elementwise_fma(i32, i32, i32);
818 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
820 v2i32 = __builtin_elementwise_fma(v2i32, v2i32, v2i32);
821 // expected-error@-1 {{1st argument must be a floating point type (was 'int2' (vector of 2 'int' values))}}
823 f32 = __builtin_elementwise_fma(f32, f32, i32);
824 // expected-error@-1 {{3rd argument must be a floating point type (was 'int')}}
826 f32 = __builtin_elementwise_fma(f32, i32, f32);
827 // expected-error@-1 {{2nd argument must be a floating point type (was 'int')}}
829 f32 = __builtin_elementwise_fma(f32, f32, i32);
830 // expected-error@-1 {{3rd argument must be a floating point type (was 'int')}}
833 _Complex float c1, c2, c3;
834 c1 = __builtin_elementwise_fma(c1, f32, f32);
835 // expected-error@-1 {{1st argument must be a floating point type (was '_Complex float')}}
837 c2 = __builtin_elementwise_fma(f32, c2, f32);
838 // expected-error@-1 {{2nd argument must be a floating point type (was '_Complex float')}}
840 c3 = __builtin_elementwise_fma(f32, f32, c3);
841 // expected-error@-1 {{3rd argument must be a floating point type (was '_Complex float')}}