1
1
// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -fpreserve-vec3-type | FileCheck %s
2
2
3
3
typedef char char3 __attribute__((ext_vector_type (3 )));
4
+ typedef char char8 __attribute__((ext_vector_type (8 )));
4
5
typedef short short3 __attribute__((ext_vector_type (3 )));
5
6
typedef double double2 __attribute__((ext_vector_type (2 )));
6
7
typedef float float3 __attribute__((ext_vector_type (3 )));
@@ -38,6 +39,15 @@ void kernel float3_to_double2(global float3 *a, global double2 *b) {
38
39
* b = __builtin_astype (* a , double2 );
39
40
}
40
41
42
+ void kernel char8_to_short3 (global short3 * a , global char8 * b ) {
43
+ // CHECK-LABEL: spir_kernel void @char8_to_short3
44
+ // CHECK: %[[IN_BC:.*]] = bitcast <8 x i8> addrspace(1)* %b to <4 x i16> addrspace(1)*
45
+ // CHECK: %[[LOAD_B:.*]] = load <4 x i16>, <4 x i16> addrspace(1)* %[[IN_BC]]
46
+ // CHECK: %[[ASTYPE:.*]] = shufflevector <4 x i16> %[[LOAD_B]], <4 x i16> poison, <3 x i32> <i32 0, i32 1, i32 2>
47
+ // CHECK: store <3 x i16> %[[ASTYPE]], <3 x i16> addrspace(1)* %a, align 8
48
+ * a = __builtin_astype (* b , short3 );
49
+ }
50
+
41
51
void from_char3 (char3 a , global int * out ) {
42
52
// CHECK-LABEL: void @from_char3
43
53
// CHECK: %[[ASTYPE:.*]] = shufflevector <3 x i8> %a, <3 x i8> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 undef>
@@ -53,3 +63,19 @@ void from_short3(short3 a, global long *out) {
53
63
// CHECK: store <4 x i16> %[[ASTYPE]], <4 x i16> addrspace(1)* %[[OUT_BC]]
54
64
* out = __builtin_astype (a , long );
55
65
}
66
+
67
+ void scalar_to_char3 (int a , global char3 * out ) {
68
+ // CHECK-LABEL: void @scalar_to_char3
69
+ // CHECK: %[[IN_BC:.*]] = bitcast i32 %a to <4 x i8>
70
+ // CHECK: %[[ASTYPE:.*]] = shufflevector <4 x i8> %[[IN_BC]], <4 x i8> poison, <3 x i32> <i32 0, i32 1, i32 2>
71
+ // CHECK: store <3 x i8> %[[ASTYPE]], <3 x i8> addrspace(1)* %out
72
+ * out = __builtin_astype (a , char3 );
73
+ }
74
+
75
+ void scalar_to_short3 (long a , global short3 * out ) {
76
+ // CHECK-LABEL: void @scalar_to_short3
77
+ // CHECK: %[[IN_BC:.*]] = bitcast i64 %a to <4 x i16>
78
+ // CHECK: %[[ASTYPE:.*]] = shufflevector <4 x i16> %[[IN_BC]], <4 x i16> poison, <3 x i32> <i32 0, i32 1, i32 2>
79
+ // CHECK: store <3 x i16> %[[ASTYPE]], <3 x i16> addrspace(1)* %out
80
+ * out = __builtin_astype (a , short3 );
81
+ }
0 commit comments