1 // RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - | FileCheck %s
3 typedef __attribute__(( ext_vector_type(3) )) char char3;
4 typedef __attribute__(( ext_vector_type(4) )) char char4;
5 typedef __attribute__(( ext_vector_type(16) )) char char16;
6 typedef __attribute__(( ext_vector_type(3) )) int int3;
8 //CHECK: define spir_func <3 x i8> @f1(<4 x i8> %[[x:.*]])
9 //CHECK: %[[astype:.*]] = shufflevector <4 x i8> %[[x]], <4 x i8> undef, <3 x i32> <i32 0, i32 1, i32 2>
10 //CHECK: ret <3 x i8> %[[astype]]
12 return __builtin_astype(x, char3);
15 //CHECK: define spir_func <4 x i8> @f2(<3 x i8> %[[x:.*]])
16 //CHECK: %[[astype:.*]] = shufflevector <3 x i8> %[[x]], <3 x i8> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 undef>
17 //CHECK: ret <4 x i8> %[[astype]]
19 return __builtin_astype(x, char4);
22 //CHECK: define spir_func <3 x i8> @f3(i32 %[[x:.*]])
23 //CHECK: %[[cast:.*]] = bitcast i32 %[[x]] to <4 x i8>
24 //CHECK: %[[astype:.*]] = shufflevector <4 x i8> %[[cast]], <4 x i8> undef, <3 x i32> <i32 0, i32 1, i32 2>
25 //CHECK: ret <3 x i8> %[[astype]]
27 return __builtin_astype(x, char3);
30 //CHECK: define spir_func <4 x i8> @f4(i32 %[[x:.*]])
31 //CHECK: %[[astype:.*]] = bitcast i32 %[[x]] to <4 x i8>
32 //CHECK-NOT: shufflevector
33 //CHECK: ret <4 x i8> %[[astype]]
35 return __builtin_astype(x, char4);
38 //CHECK: define spir_func i32 @f5(<3 x i8> %[[x:.*]])
39 //CHECK: %[[shuffle:.*]] = shufflevector <3 x i8> %[[x]], <3 x i8> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 undef>
40 //CHECK: %[[astype:.*]] = bitcast <4 x i8> %[[shuffle]] to i32
41 //CHECK: ret i32 %[[astype]]
43 return __builtin_astype(x, int);
46 //CHECK: define spir_func i32 @f6(<4 x i8> %[[x:.*]])
47 //CHECK: %[[astype:.*]] = bitcast <4 x i8> %[[x]] to i32
48 //CHECK-NOT: shufflevector
49 //CHECK: ret i32 %[[astype]]
51 return __builtin_astype(x, int);
54 //CHECK: define spir_func <3 x i8> @f7(<3 x i8> %[[x:.*]])
56 //CHECK-NOT: shufflevector
57 //CHECK: ret <3 x i8> %[[x]]
59 return __builtin_astype(x, char3);
62 //CHECK: define spir_func <3 x i32> @f8(<16 x i8> %[[x:.*]])
63 //CHECK: %[[cast:.*]] = bitcast <16 x i8> %[[x]] to <4 x i32>
64 //CHECK: %[[astype:.*]] = shufflevector <4 x i32> %[[cast]], <4 x i32> undef, <3 x i32> <i32 0, i32 1, i32 2>
65 //CHECK: ret <3 x i32> %[[astype]]
67 return __builtin_astype(x, int3);