Akira Hatanaka | 34b5dbc | 2017-09-23 05:02:02 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | typedef __fp16 half4 __attribute__ ((vector_size (8))); |
| 4 | typedef float float4 __attribute__ ((vector_size (16))); |
| 5 | typedef short short4 __attribute__ ((vector_size (8))); |
| 6 | typedef int int4 __attribute__ ((vector_size (16))); |
| 7 | |
| 8 | half4 hv0, hv1; |
| 9 | float4 fv0, fv1; |
| 10 | short4 sv0; |
| 11 | int4 iv0; |
| 12 | |
| 13 | void testFP16Vec(int c) { |
| 14 | hv0 = hv0 + hv1; |
| 15 | hv0 = hv0 - hv1; |
| 16 | hv0 = hv0 * hv1; |
| 17 | hv0 = hv0 / hv1; |
| 18 | hv0 = c ? hv0 : hv1; |
| 19 | hv0 += hv1; |
| 20 | hv0 -= hv1; |
| 21 | hv0 *= hv1; |
| 22 | hv0 /= hv1; |
| 23 | sv0 = hv0 == hv1; |
| 24 | sv0 = hv0 != hv1; |
| 25 | sv0 = hv0 < hv1; |
| 26 | sv0 = hv0 > hv1; |
| 27 | sv0 = hv0 <= hv1; |
| 28 | sv0 = hv0 >= hv1; |
| 29 | sv0 = hv0 || hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}} |
| 30 | sv0 = hv0 && hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}} |
| 31 | |
| 32 | // Implicit conversion between half vectors and float vectors are not allowed. |
| 33 | hv0 = fv0; // expected-error{{assigning to}} |
| 34 | fv0 = hv0; // expected-error{{assigning to}} |
| 35 | hv0 = (half4)fv0; // expected-error{{invalid conversion between}} |
| 36 | fv0 = (float4)hv0; // expected-error{{invalid conversion between}} |
| 37 | hv0 = fv0 + fv1; // expected-error{{assigning to}} |
| 38 | fv0 = hv0 + hv1; // expected-error{{assigning to}} |
| 39 | hv0 = hv0 + fv1; // expected-error{{cannot convert between vector}} |
| 40 | hv0 = c ? hv0 : fv1; // expected-error{{cannot convert between vector}} |
| 41 | sv0 = hv0 == fv1; // expected-error{{cannot convert between vector}} |
| 42 | sv0 = hv0 < fv1; // expected-error{{cannot convert between vector}} |
| 43 | sv0 = hv0 || fv1; // expected-error{{cannot convert between vector}} expected-error{{invalid operands to binary expression}} |
| 44 | iv0 = hv0 == hv1; // expected-error{{assigning to}} |
| 45 | |
| 46 | // FIXME: clang currently disallows using these operators on vectors, which is |
| 47 | // allowed by gcc. |
| 48 | sv0 = !hv0; // expected-error{{invalid argument type}} |
| 49 | hv0++; // expected-error{{cannot increment value of type}} |
| 50 | ++hv0; // expected-error{{cannot increment value of type}} |
| 51 | } |