| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-mavx512fp16 -O2" } */ |
| 3 |
|
| 4 |
#include <immintrin.h> |
| 5 |
|
| 6 |
typedef __bf16 __v8bf __attribute__ ((__vector_size__ (16))); |
| 7 |
typedef __bf16 __m128bf16 __attribute__ ((__vector_size__ (16), __may_alias__)); |
| 8 |
|
| 9 |
__bf16 glob_bfloat; |
| 10 |
__m128bf16 glob_bfloat_vec; |
| 11 |
|
| 12 |
__m256 is_a_float_vec; |
| 13 |
__m128 is_a_float_pair; |
| 14 |
|
| 15 |
__m128h *float_ptr; |
| 16 |
__m128h is_a_float16_vec; |
| 17 |
|
| 18 |
__v8si is_an_int_vec; |
| 19 |
__v4si is_an_int_pair; |
| 20 |
__v8hi is_a_short_vec; |
| 21 |
|
| 22 |
int is_an_int; |
| 23 |
short is_a_short_int; |
| 24 |
float is_a_float; |
| 25 |
float is_a_float16; |
| 26 |
double is_a_double; |
| 27 |
|
| 28 |
__m128bf16 footest (__m128bf16 vector0) |
| 29 |
{ |
| 30 |
/* Initialisation */ |
| 31 |
|
| 32 |
__m128bf16 vector1_1; |
| 33 |
__m128bf16 vector1_2 = glob_bfloat_vec; |
| 34 |
__m128bf16 vector1_3 = is_a_float_vec; /* { dg-error {incompatible types when initializing type '__m128bf16' {aka '__vector\(8\) __bf16'} using type '__m256'} }*/ |
| 35 |
__m128bf16 vector1_4 = is_an_int_vec; /* { dg-error {incompatible types when initializing type '__m128bf16' {aka '__vector\(8\) __bf16'} using type '__v8si'} } */ |
| 36 |
__m128bf16 vector1_5 = is_a_float16_vec; /* { dg-error {incompatible types when initializing type '__m128bf16' {aka '__vector\(8\) __bf16'} using type '__m128h'} } */ |
| 37 |
__m128bf16 vector1_6 = is_a_float_pair; /* { dg-error {incompatible types when initializing type '__m128bf16' {aka '__vector\(8\) __bf16'} using type '__m128'} } */ |
| 38 |
__m128bf16 vector1_7 = is_an_int_pair; /* { dg-error {incompatible types when initializing type '__m128bf16' {aka '__vector\(8\) __bf16'} using type '__v4si'} } */ |
| 39 |
__m128bf16 vector1_8 = is_a_short_vec; /* { dg-error {incompatible types when initializing type '__m128bf16' {aka '__vector\(8\) __bf16'} using type '__v8hi'} } */ |
| 40 |
|
| 41 |
__v8si initi_1_1 = glob_bfloat_vec; /* { dg-error {incompatible types when initializing type '__v8si' using type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 42 |
__m256 initi_1_2 = glob_bfloat_vec; /* { dg-error {incompatible types when initializing type '__m256' using type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 43 |
__m128h initi_1_3 = glob_bfloat_vec; /* { dg-error {incompatible types when initializing type '__m128h' using type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 44 |
__m128 initi_1_4 = glob_bfloat_vec; /* { dg-error {incompatible types when initializing type '__m128' using type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 45 |
__v4si initi_1_5 = glob_bfloat_vec; /* { dg-error {incompatible types when initializing type '__v4si' using type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 46 |
__v4hi initi_1_6 = glob_bfloat_vec; /* { dg-error {incompatible types when initializing type '__v4hi' using type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 47 |
|
| 48 |
__m128bf16 vector2_1 = {}; |
| 49 |
__m128bf16 vector2_2 = { glob_bfloat }; |
| 50 |
__m128bf16 vector2_3 = { glob_bfloat, glob_bfloat, glob_bfloat, glob_bfloat }; |
| 51 |
__m128bf16 vector2_4 = { 0 }; |
| 52 |
__m128bf16 vector2_5 = { 0.1 }; |
| 53 |
__m128bf16 vector2_6 = { is_a_float16 }; |
| 54 |
__m128bf16 vector2_7 = { is_a_float }; |
| 55 |
__m128bf16 vector2_8 = { is_an_int }; |
| 56 |
__m128bf16 vector2_9 = { is_a_short_int }; |
| 57 |
__m128bf16 vector2_10 = { 0.0, 0, is_a_short_int, is_a_float }; |
| 58 |
|
| 59 |
__v8si initi_2_1 = { glob_bfloat }; |
| 60 |
__m256 initi_2_2 = { glob_bfloat }; |
| 61 |
__m128h initi_2_3 = { glob_bfloat }; |
| 62 |
__m128 initi_2_4 = { glob_bfloat }; |
| 63 |
__v4si initi_2_5 = { glob_bfloat }; |
| 64 |
__v4hi initi_2_6 = { glob_bfloat }; |
| 65 |
|
| 66 |
/* Assignments to/from vectors. */ |
| 67 |
|
| 68 |
glob_bfloat_vec = glob_bfloat_vec; |
| 69 |
glob_bfloat_vec = 0; /* { dg-error {incompatible types when assigning to type '__m128bf16' {aka '__vector\(8\) __bf16'} from type 'int'} } */ |
| 70 |
glob_bfloat_vec = 0.1; /* { dg-error {incompatible types when assigning to type '__m128bf16' {aka '__vector\(8\) __bf16'} from type 'double'} } */ |
| 71 |
glob_bfloat_vec = is_a_float_vec; /* { dg-error {incompatible types when assigning to type '__m128bf16' {aka '__vector\(8\) __bf16'} from type '__m256'} } */ |
| 72 |
glob_bfloat_vec = is_an_int_vec; /* { dg-error {incompatible types when assigning to type '__m128bf16' {aka '__vector\(8\) __bf16'} from type '__v8si'} } */ |
| 73 |
glob_bfloat_vec = is_a_float16_vec; /* { dg-error {incompatible types when assigning to type '__m128bf16' {aka '__vector\(8\) __bf16'} from type '__m128h'} } */ |
| 74 |
glob_bfloat_vec = is_a_float_pair; /* { dg-error {incompatible types when assigning to type '__m128bf16' {aka '__vector\(8\) __bf16'} from type '__m128'} } */ |
| 75 |
glob_bfloat_vec = is_an_int_pair; /* { dg-error {incompatible types when assigning to type '__m128bf16' {aka '__vector\(8\) __bf16'} from type '__v4si'} } */ |
| 76 |
glob_bfloat_vec = is_a_short_vec; /* { dg-error {incompatible types when assigning to type '__m128bf16' {aka '__vector\(8\) __bf16'} from type '__v8hi'} } */ |
| 77 |
|
| 78 |
is_an_int_vec = glob_bfloat_vec; /* { dg-error {incompatible types when assigning to type '__v8si' from type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 79 |
is_a_float_vec = glob_bfloat_vec; /* { dg-error {incompatible types when assigning to type '__m256' from type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 80 |
is_a_float16_vec = glob_bfloat_vec; /* { dg-error {incompatible types when assigning to type '__m128h' from type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 81 |
is_a_float_pair = glob_bfloat_vec; /* { dg-error {incompatible types when assigning to type '__m128' from type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 82 |
is_an_int_pair = glob_bfloat_vec; /* { dg-error {incompatible types when assigning to type '__v4si' from type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 83 |
is_a_short_vec = glob_bfloat_vec;/* { dg-error {incompatible types when assigning to type '__v8hi' from type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 84 |
|
| 85 |
/* Assignments to/from elements. */ |
| 86 |
|
| 87 |
vector2_3[0] = glob_bfloat; |
| 88 |
vector2_3[0] = is_an_int; |
| 89 |
vector2_3[0] = is_a_short_int; |
| 90 |
vector2_3[0] = is_a_float; |
| 91 |
vector2_3[0] = is_a_float16; |
| 92 |
vector2_3[0] = 0; |
| 93 |
vector2_3[0] = 0.1; |
| 94 |
|
| 95 |
glob_bfloat = vector2_3[0]; |
| 96 |
is_an_int = vector2_3[0]; |
| 97 |
is_a_short_int = vector2_3[0]; |
| 98 |
is_a_float = vector2_3[0]; |
| 99 |
is_a_float16 = vector2_3[0]; |
| 100 |
|
| 101 |
/* Compound literals. */ |
| 102 |
|
| 103 |
(__m128bf16) {}; |
| 104 |
|
| 105 |
(__m128bf16) { 0 }; |
| 106 |
(__m128bf16) { 0.1 }; |
| 107 |
(__m128bf16) { is_a_float_vec }; /* { dg-error {incompatible types when initializing type '__bf16' using type '__m256'} } */ |
| 108 |
(__m128bf16) { is_an_int_vec }; /* { dg-error {incompatible types when initializing type '__bf16' using type '__v8si'} } */ |
| 109 |
(__m128bf16) { is_a_float_pair }; /* { dg-error {incompatible types when initializing type '__bf16' using type '__m128'} } */ |
| 110 |
(__m128bf16) { is_an_int_pair }; /* { dg-error {incompatible types when initializing type '__bf16' using type '__v4si'} } */ |
| 111 |
(__m128bf16) { is_a_float16_vec }; /* { dg-error {incompatible types when initializing type '__bf16' using type '__m128h'} } */ |
| 112 |
(__m128bf16) { is_a_short_vec }; /* { dg-error {incompatible types when initializing type '__bf16' using type '__v8hi'} } */ |
| 113 |
|
| 114 |
(__m128bf16) { glob_bfloat_vec }; /* { dg-error {incompatible types when initializing type '__bf16' using type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 115 |
(__v8si) { glob_bfloat_vec }; /* { dg-error {incompatible types when initializing type 'int' using type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 116 |
(__m256) { glob_bfloat_vec }; /* { dg-error {incompatible types when initializing type 'float' using type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 117 |
(__v4si) { glob_bfloat_vec }; /* { dg-error {incompatible types when initializing type 'int' using type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 118 |
(__m256h) { glob_bfloat_vec }; /* { dg-error {incompatible types when initializing type '_Float16' using type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 119 |
(__v8hi) { glob_bfloat_vec }; /* { dg-error {incompatible types when initializing type 'short int' using type '__m128bf16' {aka '__vector\(8\) __bf16'}} } */ |
| 120 |
|
| 121 |
/* Casting. */ |
| 122 |
|
| 123 |
(void) glob_bfloat_vec; |
| 124 |
(__m128bf16) glob_bfloat_vec; |
| 125 |
|
| 126 |
(__bf16) glob_bfloat_vec; /* { dg-error {vector value used where a floating-point was expected} } */ |
| 127 |
(short) glob_bfloat_vec; /* { dg-error {cannot convert a vector of type '__m128bf16' {aka '__vector\(8\) __bf16'} to type 'short int' which has different size} } */ |
| 128 |
(int) glob_bfloat_vec; /* { dg-error {cannot convert a vector of type '__m128bf16' {aka '__vector\(8\) __bf16'} to type 'int' which has different size} } */ |
| 129 |
(_Float16) glob_bfloat_vec; /* { dg-error {vector value used where a floating-point was expected} } */ |
| 130 |
(float) glob_bfloat_vec; /* { dg-error {vector value used where a floating-point was expected} } */ |
| 131 |
(double) glob_bfloat_vec; /* { dg-error {vector value used where a floating-point was expected} } */ |
| 132 |
|
| 133 |
(__v8si) glob_bfloat_vec; /* { dg-error {cannot convert a value of type '__m128bf16' {aka '__vector\(8\) __bf16'} to vector type '__vector\(8\) int' which has different size} } */ |
| 134 |
(__m256) glob_bfloat_vec; /* { dg-error {cannot convert a value of type '__m128bf16' {aka '__vector\(8\) __bf16'} to vector type '__vector\(8\) float' which has different size} } */ |
| 135 |
(__m128h) glob_bfloat_vec; |
| 136 |
(__v4si) glob_bfloat_vec; |
| 137 |
(__m128) glob_bfloat_vec; |
| 138 |
(__v8hi) glob_bfloat_vec; |
| 139 |
|
| 140 |
(__m128bf16) is_an_int_vec; /* { dg-error {cannot convert a value of type '__v8si' to vector type '__vector\(8\) __bf16' which has different size} } */ |
| 141 |
(__m128bf16) is_a_float_vec; /* { dg-error {cannot convert a value of type '__m256' to vector type '__vector\(8\) __bf16' which has different size} } */ |
| 142 |
(__m128bf16) is_a_float16_vec; |
| 143 |
(__m128bf16) is_an_int_pair; |
| 144 |
(__m128bf16) is_a_float_pair; |
| 145 |
(__m128bf16) is_a_short_vec; |
| 146 |
(__m128bf16) is_a_double; /* { dg-error {cannot convert value to a vector} } */ |
| 147 |
|
| 148 |
/* Arrays and Structs. */ |
| 149 |
|
| 150 |
typedef __m128bf16 array_type[2]; |
| 151 |
extern __m128bf16 extern_array[]; |
| 152 |
|
| 153 |
__m128bf16 array[2]; |
| 154 |
__m128bf16 zero_length_array[0]; |
| 155 |
__m128bf16 empty_init_array[] = {}; |
| 156 |
typedef __m128bf16 some_other_type[is_an_int]; |
| 157 |
|
| 158 |
struct struct1 { |
| 159 |
__m128bf16 a; |
| 160 |
}; |
| 161 |
|
| 162 |
union union1 { |
| 163 |
__m128bf16 a; |
| 164 |
}; |
| 165 |
|
| 166 |
/* Addressing and dereferencing. */ |
| 167 |
|
| 168 |
__m128bf16 *bfloat_ptr = &vector0; |
| 169 |
vector0 = *bfloat_ptr; |
| 170 |
|
| 171 |
/* Pointer assignment. */ |
| 172 |
|
| 173 |
__m128bf16 *bfloat_ptr2 = bfloat_ptr; |
| 174 |
__m128bf16 *bfloat_ptr3 = array; |
| 175 |
|
| 176 |
/* Pointer arithmetic. */ |
| 177 |
|
| 178 |
++bfloat_ptr; |
| 179 |
--bfloat_ptr; |
| 180 |
bfloat_ptr++; |
| 181 |
bfloat_ptr--; |
| 182 |
bfloat_ptr += 1; |
| 183 |
bfloat_ptr -= 1; |
| 184 |
bfloat_ptr - bfloat_ptr2; |
| 185 |
bfloat_ptr = &bfloat_ptr3[0]; |
| 186 |
bfloat_ptr = &bfloat_ptr3[1]; |
| 187 |
|
| 188 |
/* Simple comparison. */ |
| 189 |
vector0 > glob_bfloat_vec; |
| 190 |
glob_bfloat_vec == vector0; |
| 191 |
vector0 > is_a_float_vec; /* { dg-error {comparing vectors with different element types} } */ |
| 192 |
is_a_float_vec == vector0; /* { dg-error {comparing vectors with different element types} } */ |
| 193 |
vector0 > 0; |
| 194 |
0 == vector0; |
| 195 |
vector0 > 0.1; /* { dg-error {conversion of scalar 'double' to vector '__m128bf16'} } */ |
| 196 |
0.1 == vector0; /* { dg-error {conversion of scalar 'double' to vector '__m128bf16'} } */ |
| 197 |
vector0 > is_an_int_vec; /* { dg-error {comparing vectors with different element types} } */ |
| 198 |
is_an_int_vec == vector0; /* { dg-error {comparing vectors with different element types} } */ |
| 199 |
|
| 200 |
/* Pointer comparison. */ |
| 201 |
|
| 202 |
bfloat_ptr == &vector0; |
| 203 |
bfloat_ptr != &vector0; |
| 204 |
bfloat_ptr < &vector0; |
| 205 |
bfloat_ptr <= &vector0; |
| 206 |
bfloat_ptr > &vector0; |
| 207 |
bfloat_ptr >= &vector0; |
| 208 |
bfloat_ptr == bfloat_ptr2; |
| 209 |
bfloat_ptr != bfloat_ptr2; |
| 210 |
bfloat_ptr < bfloat_ptr2; |
| 211 |
bfloat_ptr <= bfloat_ptr2; |
| 212 |
bfloat_ptr > bfloat_ptr2; |
| 213 |
bfloat_ptr >= bfloat_ptr2; |
| 214 |
|
| 215 |
/* Conditional expressions. */ |
| 216 |
|
| 217 |
0 ? vector0 : vector0; |
| 218 |
0 ? vector0 : is_a_float_vec; /* { dg-error {type mismatch in conditional expression} } */ |
| 219 |
0 ? is_a_float_vec : vector0; /* { dg-error {type mismatch in conditional expression} } */ |
| 220 |
0 ? vector0 : is_a_float16_vec; /* { dg-error {type mismatch in conditional expression} } */ |
| 221 |
0 ? is_a_float16_vec : vector0; /* { dg-error {type mismatch in conditional expression} } */ |
| 222 |
0 ? vector0 : 0; /* { dg-error {type mismatch in conditional expression} } */ |
| 223 |
0 ? 0 : vector0; /* { dg-error {type mismatch in conditional expression} } */ |
| 224 |
0 ? 0.1 : vector0; /* { dg-error {type mismatch in conditional expression} } */ |
| 225 |
0 ? vector0 : 0.1; /* { dg-error {type mismatch in conditional expression} } */ |
| 226 |
0 ? bfloat_ptr : bfloat_ptr2; |
| 227 |
0 ? bfloat_ptr : float_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */ |
| 228 |
0 ? float_ptr : bfloat_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */ |
| 229 |
|
| 230 |
vector0 ? vector0 : vector0; /* { dg-error {used vector type where scalar is required} } */ |
| 231 |
vector0 ? is_a_float16_vec : vector0; /* { dg-error {used vector type where scalar is required} } */ |
| 232 |
vector0 ? vector0 : is_a_float16_vec; /* { dg-error {used vector type where scalar is required} } */ |
| 233 |
vector0 ? is_a_float16_vec : is_a_float16_vec; /* { dg-error {used vector type where scalar is required} } */ |
| 234 |
|
| 235 |
/* Unary operators. */ |
| 236 |
|
| 237 |
+vector0; |
| 238 |
-vector0; |
| 239 |
~vector0; /* { dg-error {wrong type argument to bit-complement} } */ |
| 240 |
!vector0; /* { dg-error {wrong type argument to unary exclamation mark} } */ |
| 241 |
*vector0; /* { dg-error {invalid type argument of unary '\*'} } */ |
| 242 |
__real vector0; /* { dg-error {wrong type argument to __real} } */ |
| 243 |
__imag vector0; /* { dg-error {wrong type argument to __imag} } */ |
| 244 |
++vector0; |
| 245 |
--vector0; |
| 246 |
vector0++; |
| 247 |
vector0--; |
| 248 |
|
| 249 |
/* Binary arithmetic operations. */ |
| 250 |
|
| 251 |
vector0 = glob_bfloat_vec + *bfloat_ptr; |
| 252 |
vector0 = glob_bfloat_vec + 0.1; /* { dg-error {conversion of scalar 'double' to vector '__m128bf16'} } */ |
| 253 |
vector0 = glob_bfloat_vec + 0; |
| 254 |
vector0 = glob_bfloat_vec + is_a_float_vec; /* { dg-error {invalid operands to binary \+} } */ |
| 255 |
|
| 256 |
return vector0; |
| 257 |
} |
| 258 |
|