1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
|
// RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
template <typename X>
using matrix_4_4 = X __attribute__((matrix_type(4, 4)));
template <typename Y>
using matrix_5_5 = Y __attribute__((matrix_type(5, 5)));
// CHECK-LABEL: define{{.*}} void @_Z25CastCharMatrixToIntCStylev()
void CastCharMatrixToIntCStyle() {
// CHECK: [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
// CHECK-NEXT: [[CONV:%.*]] = sext <25 x i8> [[C]] to <25 x i32>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i32]* {{.*}} to <25 x i32>*
// CHECK-NEXT: store <25 x i32> [[CONV]], <25 x i32>* [[CONV1]], align 4
matrix_5_5<char> c;
matrix_5_5<int> i;
i = (matrix_5_5<int>)c;
}
// CHECK-LABEL: define{{.*}} void @_Z29CastCharMatrixToIntStaticCastv()
void CastCharMatrixToIntStaticCast() {
// CHECK: [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
// CHECK-NEXT: [[CONV:%.*]] = sext <25 x i8> [[C]] to <25 x i32>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i32]* {{.*}} to <25 x i32>*
// CHECK-NEXT: store <25 x i32> [[CONV]], <25 x i32>* [[CONV1]], align 4
matrix_5_5<char> c;
matrix_5_5<int> i;
i = static_cast<matrix_5_5<int>>(c);
}
// CHECK-LABEL: define{{.*}} void @_Z33CastCharMatrixToUnsignedIntCStylev
void CastCharMatrixToUnsignedIntCStyle() {
// CHECK: [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
// CHECK-NEXT: [[CONV:%.*]] = sext <25 x i8> [[C]] to <25 x i32>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i32]* {{.*}} to <25 x i32>*
// CHECK-NEXT: store <25 x i32> [[CONV]], <25 x i32>* [[CONV1]], align 4
// CHECK-NEXT: ret void
matrix_5_5<char> c;
matrix_5_5<unsigned int> u;
u = (matrix_5_5<unsigned int>)c;
}
// CHECK-LABEL: define{{.*}} void @_Z37CastCharMatrixToUnsignedIntStaticCastv
void CastCharMatrixToUnsignedIntStaticCast() {
// CHECK: [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
// CHECK-NEXT: [[CONV:%.*]] = sext <25 x i8> [[C]] to <25 x i32>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i32]* {{.*}} to <25 x i32>*
// CHECK-NEXT: store <25 x i32> [[CONV]], <25 x i32>* [[CONV1]], align 4
// CHECK-NEXT: ret void
matrix_5_5<char> c;
matrix_5_5<unsigned int> u;
u = static_cast<matrix_5_5<unsigned int>>(c);
}
// CHECK-LABEL: define{{.*}} void @_Z38CastUnsignedLongIntMatrixToShortCStylev
void CastUnsignedLongIntMatrixToShortCStyle() {
// CHECK: [[U:%.*]] = load <25 x i64>, <25 x i64>* {{.*}}, align 8
// CHECK-NEXT: [[CONV:%.*]] = trunc <25 x i64> {{.*}} to <25 x i16>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i16]* {{.*}} to <25 x i16>*
// CHECK-NEXT: store <25 x i16> [[CONV]], <25 x i16>* [[CONV1]], align 2
// CHECK-NEXT: ret void
matrix_5_5<unsigned long int> u;
matrix_5_5<short int> s;
s = (matrix_5_5<short int>)u;
}
// CHECK-LABEL: define{{.*}} void @_Z42CastUnsignedLongIntMatrixToShortStaticCastv
void CastUnsignedLongIntMatrixToShortStaticCast() {
// CHECK: [[U:%.*]] = load <25 x i64>, <25 x i64>* {{.*}}, align 8
// CHECK-NEXT: [[CONV:%.*]] = trunc <25 x i64> {{.*}} to <25 x i16>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i16]* {{.*}} to <25 x i16>*
// CHECK-NEXT: store <25 x i16> [[CONV]], <25 x i16>* [[CONV1]], align 2
// CHECK-NEXT: ret void
matrix_5_5<unsigned long int> u;
matrix_5_5<short int> s;
s = static_cast<matrix_5_5<short int>>(u);
}
// CHECK-LABEL: define{{.*}} void @_Z26CastIntMatrixToShortCStylev()
void CastIntMatrixToShortCStyle() {
// CHECK: [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
// CHECK-NEXT: [[CONV:%.*]] = trunc <25 x i32> [[I]] to <25 x i16>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i16]* {{.*}} to <25 x i16>*
// CHECK-NEXT: store <25 x i16> [[CONV]], <25 x i16>* [[CONV1]], align 2
// CHECK-NEXT: ret void
matrix_5_5<int> i;
matrix_5_5<short int> s;
s = (matrix_5_5<short int>)i;
}
// CHECK-LABEL: define{{.*}} void @_Z30CastIntMatrixToShortStaticCastv()
void CastIntMatrixToShortStaticCast() {
// CHECK: [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
// CHECK-NEXT: [[CONV:%.*]] = trunc <25 x i32> [[I]] to <25 x i16>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i16]* {{.*}} to <25 x i16>*
// CHECK-NEXT: store <25 x i16> [[CONV]], <25 x i16>* [[CONV1]], align 2
// CHECK-NEXT: ret void
matrix_5_5<int> i;
matrix_5_5<short int> s;
s = static_cast<matrix_5_5<short int>>(i);
}
// CHECK-LABEL: define{{.*}} void @_Z26CastIntMatrixToFloatCStylev()
void CastIntMatrixToFloatCStyle() {
// CHECK: [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
// CHECK-NEXT: [[CONV]] = sitofp <25 x i32> {{.*}} to <25 x float>
// CHECK-NEXT: [[CONV1]] = bitcast [25 x float]* {{.*}} to <25 x float>*
// CHECK-NEXT: store <25 x float> [[CONV]], <25 x float>* [[CONV1]], align 4
// CHECK-NEXT: ret void
matrix_5_5<int> i;
matrix_5_5<float> f;
f = (matrix_5_5<float>)i;
}
// CHECK-LABEL: define{{.*}} void @_Z30CastIntMatrixToFloatStaticCastv()
void CastIntMatrixToFloatStaticCast() {
// CHECK: [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
// CHECK-NEXT: [[CONV]] = sitofp <25 x i32> {{.*}} to <25 x float>
// CHECK-NEXT: [[CONV1]] = bitcast [25 x float]* {{.*}} to <25 x float>*
// CHECK-NEXT: store <25 x float> [[CONV]], <25 x float>* [[CONV1]], align 4
// CHECK-NEXT: ret void
matrix_5_5<int> i;
matrix_5_5<float> f;
f = static_cast<matrix_5_5<float>>(i);
}
// CHECK-LABEL: define{{.*}} void @_Z34CastUnsignedIntMatrixToFloatCStylev()
void CastUnsignedIntMatrixToFloatCStyle() {
// CHECK: [[U:%.*]] = load <25 x i16>, <25 x i16>* {{.*}}, align 2
// CHECK-NEXT: [[CONV:%.*]] = uitofp <25 x i16> [[U]] to <25 x float>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x float]* {{.*}} to <25 x float>*
// CHECK-NEXT: store <25 x float> [[CONV]], <25 x float>* {{.*}}, align 4
// CHECK-NEXT: ret void
matrix_5_5<unsigned short int> u;
matrix_5_5<float> f;
f = (matrix_5_5<float>)u;
}
// CHECK-LABEL: define{{.*}} void @_Z38CastUnsignedIntMatrixToFloatStaticCastv()
void CastUnsignedIntMatrixToFloatStaticCast() {
// CHECK: [[U:%.*]] = load <25 x i16>, <25 x i16>* {{.*}}, align 2
// CHECK-NEXT: [[CONV:%.*]] = uitofp <25 x i16> [[U]] to <25 x float>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x float]* {{.*}} to <25 x float>*
// CHECK-NEXT: store <25 x float> [[CONV]], <25 x float>* {{.*}}, align 4
// CHECK-NEXT: ret void
matrix_5_5<unsigned short int> u;
matrix_5_5<float> f;
f = static_cast<matrix_5_5<float>>(u);
}
// CHECK-LABEL: define{{.*}} void @_Z27CastDoubleMatrixToIntCStylev()
void CastDoubleMatrixToIntCStyle() {
// CHECK: [[D:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8
// CHECK-NEXT: [[CONV:%.*]] = fptosi <25 x double> [[D]] to <25 x i32>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i32]* %i to <25 x i32>*
// CHECK-NEXT: store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4
// CHECK-NEXT: ret void
matrix_5_5<double> d;
matrix_5_5<int> i;
i = (matrix_5_5<int>)d;
}
// CHECK-LABEL: define{{.*}} void @_Z31CastDoubleMatrixToIntStaticCastv()
void CastDoubleMatrixToIntStaticCast() {
// CHECK: [[D:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8
// CHECK-NEXT: [[CONV:%.*]] = fptosi <25 x double> [[D]] to <25 x i32>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i32]* %i to <25 x i32>*
// CHECK-NEXT: store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4
// CHECK-NEXT: ret void
matrix_5_5<double> d;
matrix_5_5<int> i;
i = static_cast<matrix_5_5<int>>(d);
}
// CHECK-LABEL: define{{.*}} void @_Z39CastFloatMatrixToUnsignedShortIntCStylev()
void CastFloatMatrixToUnsignedShortIntCStyle() {
// CHECK: [[F:%.*]] = load <25 x float>, <25 x float>* {{.*}}, align 4
// CHECK-NEXT: [[CONV:%.*]] = fptoui <25 x float> [[F]] to <25 x i16>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i16]* {{.*}} to <25 x i16>*
// CHECK-NEXT: store <25 x i16> [[CONV]], <25 x i16>* [[CONV1]], align 2
// CHECK-NEXT: ret void
matrix_5_5<float> f;
matrix_5_5<unsigned short int> i;
i = (matrix_5_5<unsigned short int>)f;
}
// CHECK-LABEL: define{{.*}} void @_Z43CastFloatMatrixToUnsignedShortIntStaticCastv()
void CastFloatMatrixToUnsignedShortIntStaticCast() {
// CHECK: [[F:%.*]] = load <25 x float>, <25 x float>* {{.*}}, align 4
// CHECK-NEXT: [[CONV:%.*]] = fptoui <25 x float> [[F]] to <25 x i16>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i16]* {{.*}} to <25 x i16>*
// CHECK-NEXT: store <25 x i16> [[CONV]], <25 x i16>* [[CONV1]], align 2
// CHECK-NEXT: ret void
matrix_5_5<float> f;
matrix_5_5<unsigned short int> i;
i = static_cast<matrix_5_5<unsigned short int>>(f);
}
// CHECK-LABEL: define{{.*}} void @_Z29CastDoubleMatrixToFloatCStylev()
void CastDoubleMatrixToFloatCStyle() {
// CHECK: [[D:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8
// CHECK-NEXT: [[CONV:%.*]] = fptrunc <25 x double> [[D]] to <25 x float>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x float]* {{.*}} to <25 x float>*
// CHECK-NEXT: store <25 x float> [[CONV]], <25 x float>* [[CONV1]], align 4
// CHECK-NEXT: ret void
matrix_5_5<double> d;
matrix_5_5<float> f;
f = (matrix_5_5<float>)d;
}
// CHECK-LABEL: define{{.*}} void @_Z33CastDoubleMatrixToFloatStaticCastv()
void CastDoubleMatrixToFloatStaticCast() {
// CHECK: [[D:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8
// CHECK-NEXT: [[CONV:%.*]] = fptrunc <25 x double> [[D]] to <25 x float>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x float]* {{.*}} to <25 x float>*
// CHECK-NEXT: store <25 x float> [[CONV]], <25 x float>* [[CONV1]], align 4
// CHECK-NEXT: ret void
matrix_5_5<double> d;
matrix_5_5<float> f;
f = static_cast<matrix_5_5<float>>(d);
}
// CHECK-LABEL: define{{.*}} void @_Z39CastUnsignedShortIntToUnsignedIntCStylev()
void CastUnsignedShortIntToUnsignedIntCStyle() {
// CHECK: [[S:%.*]] = load <25 x i16>, <25 x i16>* {{.*}}, align 2
// CHECK-NEXT: [[CONV:%.*]] = zext <25 x i16> [[S]] to <25 x i32>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i32]* {{.*}} to <25 x i32>*
// CHECK-NEXT: store <25 x i32> [[CONV]], <25 x i32>* [[CONV1]], align 4
// CHECK-NEXT: ret void
matrix_5_5<unsigned short int> s;
matrix_5_5<unsigned int> i;
i = (matrix_5_5<unsigned int>)s;
}
// CHECK-LABEL: define{{.*}} void @_Z43CastUnsignedShortIntToUnsignedIntStaticCastv()
void CastUnsignedShortIntToUnsignedIntStaticCast() {
// CHECK: [[S:%.*]] = load <25 x i16>, <25 x i16>* {{.*}}, align 2
// CHECK-NEXT: [[CONV:%.*]] = zext <25 x i16> [[S]] to <25 x i32>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i32]* {{.*}} to <25 x i32>*
// CHECK-NEXT: store <25 x i32> [[CONV]], <25 x i32>* [[CONV1]], align 4
// CHECK-NEXT: ret void
matrix_5_5<unsigned short int> s;
matrix_5_5<unsigned int> i;
i = static_cast<matrix_5_5<unsigned int>>(s);
}
// CHECK-LABEL: define{{.*}} void @_Z43CastUnsignedLongIntToUnsignedShortIntCStylev()
void CastUnsignedLongIntToUnsignedShortIntCStyle() {
// CHECK: [[L:%.*]] = load <25 x i64>, <25 x i64>* %0, align 8
// CHECK-NEXT: [[CONV:%.*]] = trunc <25 x i64> [[L]] to <25 x i16>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i16]* {{.*}} to <25 x i16>*
// CHECK-NEXT: store <25 x i16> [[CONV]], <25 x i16>* [[CONV1]], align 2
// CHECK-NEXT: ret void
matrix_5_5<unsigned long int> l;
matrix_5_5<unsigned short int> s;
s = (matrix_5_5<unsigned short int>)l;
}
// CHECK-LABEL: define{{.*}} void @_Z47CastUnsignedLongIntToUnsignedShortIntStaticCastv()
void CastUnsignedLongIntToUnsignedShortIntStaticCast() {
// CHECK: [[L:%.*]] = load <25 x i64>, <25 x i64>* %0, align 8
// CHECK-NEXT: [[CONV:%.*]] = trunc <25 x i64> [[L]] to <25 x i16>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i16]* {{.*}} to <25 x i16>*
// CHECK-NEXT: store <25 x i16> [[CONV]], <25 x i16>* [[CONV1]], align 2
// CHECK-NEXT: ret void
matrix_5_5<unsigned long int> l;
matrix_5_5<unsigned short int> s;
s = static_cast<matrix_5_5<unsigned short int>>(l);
}
// CHECK-LABEL: define{{.*}} void @_Z31CastUnsignedShortIntToIntCStylev()
void CastUnsignedShortIntToIntCStyle() {
// CHECK: [[U:%.*]] = load <25 x i16>, <25 x i16>* %0, align 2
// CHECK-NEXT: [[CONV:%.*]] = zext <25 x i16> [[U]] to <25 x i32>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i32]* {{.*}} to <25 x i32>*
// CHECK-NEXT: store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4
// CHECK-NEXT: ret void
matrix_5_5<unsigned short int> u;
matrix_5_5<int> i;
i = (matrix_5_5<int>)u;
}
// CHECK-LABEL: define{{.*}} void @_Z35CastUnsignedShortIntToIntStaticCastv()
void CastUnsignedShortIntToIntStaticCast() {
// CHECK: [[U:%.*]] = load <25 x i16>, <25 x i16>* %0, align 2
// CHECK-NEXT: [[CONV:%.*]] = zext <25 x i16> [[U]] to <25 x i32>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i32]* {{.*}} to <25 x i32>*
// CHECK-NEXT: store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4
// CHECK-NEXT: ret void
matrix_5_5<unsigned short int> u;
matrix_5_5<int> i;
i = static_cast<matrix_5_5<int>>(u);
}
// CHECK-LABEL: define{{.*}} void @_Z30CastIntToUnsignedLongIntCStylev()
void CastIntToUnsignedLongIntCStyle() {
// CHECK: [[I:%.*]] = load <25 x i32>, <25 x i32>* %0, align 4
// CHECK-NEXT: [[CONV:%.*]] = sext <25 x i32> [[I]] to <25 x i64>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i64]* {{.*}} to <25 x i64>*
// CHECK-NEXT: store <25 x i64> [[CONV]], <25 x i64>* {{.*}}, align 8
// CHECK-NEXT: ret void
matrix_5_5<int> i;
matrix_5_5<unsigned long int> u;
u = (matrix_5_5<unsigned long int>)i;
}
// CHECK-LABEL: define{{.*}} void @_Z34CastIntToUnsignedLongIntStaticCastv()
void CastIntToUnsignedLongIntStaticCast() {
// CHECK: [[I:%.*]] = load <25 x i32>, <25 x i32>* %0, align 4
// CHECK-NEXT: [[CONV:%.*]] = sext <25 x i32> [[I]] to <25 x i64>
// CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i64]* {{.*}} to <25 x i64>*
// CHECK-NEXT: store <25 x i64> [[CONV]], <25 x i64>* {{.*}}, align 8
// CHECK-NEXT: ret void
matrix_5_5<int> i;
matrix_5_5<unsigned long int> u;
u = static_cast<matrix_5_5<unsigned long int>>(i);
}
class Foo {
int x[10];
public:
Foo(matrix_5_5<int> x);
};
Foo class_constructor_matrix_ty(matrix_5_5<int> m) {
// CHECK-LABEL: define void @_Z27class_constructor_matrix_tyu11matrix_typeILm5ELm5EiE(%class.Foo* noalias sret(%class.Foo) align 4 %agg.result, <25 x i32> noundef %m)
// CHECK: [[M:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
// CHECK-NEXT: call void @_ZN3FooC1Eu11matrix_typeILm5ELm5EiE(%class.Foo* noundef nonnull align 4 dereferenceable(40) %agg.result, <25 x i32> noundef [[M]])
// CHECK-NEXT: ret void
return Foo(m);
}
struct Bar {
float x[10];
Bar(matrix_4_4<float> x);
};
Bar struct_constructor_matrix_ty(matrix_4_4<float> m) {
// CHECK-LABEL: define void @_Z28struct_constructor_matrix_tyu11matrix_typeILm4ELm4EfE(%struct.Bar* noalias sret(%struct.Bar) align 4 %agg.result, <16 x float> noundef %m)
// CHECK: [[M:%.*]] = load <16 x float>, <16 x float>* {{.*}}, align 4
// CHECK-NEXT: call void @_ZN3BarC1Eu11matrix_typeILm4ELm4EfE(%struct.Bar* noundef nonnull align 4 dereferenceable(40) %agg.result, <16 x float> noundef [[M]])
// CHECK-NEXT: ret void
return Bar(m);
}
|