[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenOpenCL / vector_literals.cl
blobd8d36c7ea493f4fa2c34279bcb39476f72f21246
1 // RUN: %clang_cc1 -emit-llvm %s -o - -O0 | FileCheck %s
2 // RUN: %clang_cc1 -emit-llvm %s -o - -cl-std=clc++ -O0 | FileCheck %s
4 typedef __attribute__((ext_vector_type(2))) int int2;
5 typedef __attribute__((ext_vector_type(3))) int int3;
6 typedef __attribute__((ext_vector_type(4))) int int4;
7 typedef __attribute__((ext_vector_type(8))) int int8;
8 typedef __attribute__((ext_vector_type(4))) float float4;
10 __constant const int4 c1 = (int4)(1, 2, ((int2)(3)));
11 // CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 3>
13 __constant const int4 c2 = (int4)(1, 2, ((int2)(3, 4)));
14 // CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 4>
16 void vector_literals_valid() {
17 //CHECK: insertelement <4 x i32> <i32 1, i32 2, i32 undef, i32 undef>, i32 %{{.+}}, i32 2
18 //CHECK: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 3
19 int4 a_1_1_1_1 = (int4)(1, 2, c1.s2, c2.s3);
21 //CHECK: store <2 x i32> <i32 1, i32 2>, ptr
22 //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
23 //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
24 //CHECK: insertelement <4 x i32> %{{.+}}, i32 3, i32 2
25 //CHECK: insertelement <4 x i32> %{{.+}}, i32 4, i32 3
26 int4 a_2_1_1 = (int4)((int2)(1, 2), 3, 4);
28 //CHECK: store <2 x i32> <i32 2, i32 3>, ptr
29 //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
30 //CHECK: shufflevector <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>, <4 x i32> %{{.+}}, <4 x i32> <i32 0, i32 4, i32 5, i32 undef>
31 //CHECK: insertelement <4 x i32> %{{.+}}, i32 4, i32 3
32 int4 a_1_2_1 = (int4)(1, (int2)(2, 3), 4);
34 //CHECK: store <2 x i32> <i32 3, i32 4>, ptr
35 //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
36 //CHECK: shufflevector <4 x i32> <i32 1, i32 2, i32 undef, i32 undef>, <4 x i32> %{{.+}}, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
37 int4 a_1_1_2 = (int4)(1, 2, (int2)(3, 4));
39 //CHECK: store <2 x i32> <i32 1, i32 2>, ptr
40 //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
41 //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
42 //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> <i32 3, i32 3, i32 undef, i32 undef>, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
43 int4 a_2_2 = (int4)((int2)(1, 2), (int2)(3));
45 //CHECK: store <4 x i32> <i32 2, i32 3, i32 4, i32 undef>, ptr
46 //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> poison, <3 x i32> <i32 0, i32 1, i32 2>
47 //CHECK: shufflevector <3 x i32> %{{.+}}, <3 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 undef>
48 //CHECK: shufflevector <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>, <4 x i32> %{{.+}}, <4 x i32> <i32 0, i32 4, i32 5, i32 6>
49 int4 a_1_3 = (int4)(1, (int3)(2, 3, 4));
51 //CHECK: store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %a
52 int4 a = (int4)(1);
54 //CHECK: load <4 x i32>, ptr %a
55 //CHECK: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> poison, <2 x i32> <i32 0, i32 1>
56 //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> poison, <8 x i32> <i32 0, i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
57 //CHECK: shufflevector <8 x i32> <i32 1, i32 2, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>, <8 x i32> %{{.+}}, <8 x i32> <i32 0, i32 1, i32 8, i32 9, i32 undef, i32 undef, i32 undef, i32 undef>
58 //CHECK: load <4 x i32>, ptr %a
59 //CHECK: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
60 //CHECK: shufflevector <8 x i32> %{{.+}}, <8 x i32> %{{.+}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11>
61 int8 b = (int8)(1, 2, a.xy, a);
63 //CHECK: store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, ptr %V2
64 float4 V2 = (float4)(1);
67 void vector_literals_with_cast() {
68 // CHECK-LABEL: vector_literals_with_cast
69 // CHECK: store <2 x i32> <i32 12, i32 34>, ptr
70 // CHECK: extractelement <2 x i32> %{{[0-9]+}}, i{{[0-9]+}} 0
71 unsigned int withCast = ((int2)((int2)(12, 34))).s0;