]> granicus.if.org Git - clang/blob - test/CodeGenOpenCL/as_type.cl
Revert r275678, "Revert "Revert r275027 - Let FuncAttrs infer the 'returned' argument...
[clang] / test / CodeGenOpenCL / as_type.cl
1 // RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - | FileCheck %s
2
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;
7
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]]
11 char3 f1(char4 x) {
12   return  __builtin_astype(x, char3);
13 }
14
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]]
18 char4 f2(char3 x) {
19   return __builtin_astype(x, char4);
20 }
21
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]]
26 char3 f3(int x) {
27   return __builtin_astype(x, char3);
28 }
29
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]]
34 char4 f4(int x) {
35   return __builtin_astype(x, char4);
36 }
37
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]]
42 int f5(char3 x) {
43   return __builtin_astype(x, int);
44 }
45
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]]
50 int f6(char4 x) {
51   return __builtin_astype(x, int);
52 }
53
54 //CHECK: define spir_func <3 x i8> @f7(<3 x i8> %[[x:.*]])
55 //CHECK-NOT: bitcast
56 //CHECK-NOT: shufflevector
57 //CHECK: ret <3 x i8> %[[x]]
58 char3 f7(char3 x) {
59   return __builtin_astype(x, char3);
60 }
61
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]]
66 int3 f8(char16 x) {
67   return __builtin_astype(x, int3);
68 }