aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGenOpenCL
diff options
context:
space:
mode:
authorAnastasia Stulova <anastasia.stulova@arm.com>2019-08-02 11:19:35 +0000
committerAnastasia Stulova <anastasia.stulova@arm.com>2019-08-02 11:19:35 +0000
commit91a14f64f769263deea649999cea32ea5bfa14cd (patch)
treed56939a4304243bbf7ade00ed65f6751dbd10133 /test/CodeGenOpenCL
parent0743ec24e3b1a47b0642a280e3499e8b741199ab (diff)
[OpenCL] Allow OpenCL C style vector initialization in C++
Allow creating vector literals from other vectors. float4 a = (float4)(1.0f, 2.0f, 3.0f, 4.0f); float4 v = (float4)(a.s23, a.s01); Differential revision: https://reviews.llvm.org/D65286 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367675 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenOpenCL')
-rw-r--r--test/CodeGenOpenCL/vector_literals_nested.cl23
-rw-r--r--test/CodeGenOpenCL/vector_literals_valid.cl75
2 files changed, 59 insertions, 39 deletions
diff --git a/test/CodeGenOpenCL/vector_literals_nested.cl b/test/CodeGenOpenCL/vector_literals_nested.cl
deleted file mode 100644
index b9013d0482..0000000000
--- a/test/CodeGenOpenCL/vector_literals_nested.cl
+++ /dev/null
@@ -1,23 +0,0 @@
-// RUN: %clang_cc1 %s -emit-llvm -O3 -o - | FileCheck %s
-
-typedef int int2 __attribute((ext_vector_type(2)));
-typedef int int4 __attribute((ext_vector_type(4)));
-
-__constant const int4 itest1 = (int4)(1, 2, ((int2)(3, 4)));
-// CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 4>
-__constant const int4 itest2 = (int4)(1, 2, ((int2)(3)));
-// CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 3>
-
-typedef float float2 __attribute((ext_vector_type(2)));
-typedef float float4 __attribute((ext_vector_type(4)));
-
-void ftest1(float4 *p) {
- *p = (float4)(1.1f, 1.2f, ((float2)(1.3f, 1.4f)));
-// CHECK: store <4 x float> <float 0x3FF19999A0000000, float 0x3FF3333340000000, float 0x3FF4CCCCC0000000, float 0x3FF6666660000000>
-}
-
-float4 ftest2(float4 *p) {
- *p = (float4)(1.1f, 1.2f, ((float2)(1.3f)));
-// CHECK: store <4 x float> <float 0x3FF19999A0000000, float 0x3FF3333340000000, float 0x3FF4CCCCC0000000, float 0x3FF4CCCCC0000000>
-}
-
diff --git a/test/CodeGenOpenCL/vector_literals_valid.cl b/test/CodeGenOpenCL/vector_literals_valid.cl
index bba5b23e23..5aa7ae4a4b 100644
--- a/test/CodeGenOpenCL/vector_literals_valid.cl
+++ b/test/CodeGenOpenCL/vector_literals_valid.cl
@@ -1,22 +1,65 @@
-// RUN: %clang_cc1 -emit-llvm %s -o %t
+// RUN: %clang_cc1 -emit-llvm %s -o - -O0 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -cl-std=clc++ -O0 | FileCheck %s
-typedef __attribute__(( ext_vector_type(2) )) int int2;
-typedef __attribute__(( ext_vector_type(3) )) int int3;
-typedef __attribute__(( ext_vector_type(4) )) int int4;
-typedef __attribute__(( ext_vector_type(8) )) int int8;
-typedef __attribute__(( ext_vector_type(4) )) float float4;
+typedef __attribute__((ext_vector_type(2))) int int2;
+typedef __attribute__((ext_vector_type(3))) int int3;
+typedef __attribute__((ext_vector_type(4))) int int4;
+typedef __attribute__((ext_vector_type(8))) int int8;
+typedef __attribute__((ext_vector_type(4))) float float4;
+
+__constant const int4 c1 = (int4)(1, 2, ((int2)(3)));
+// CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 3>
+
+__constant const int4 c2 = (int4)(1, 2, ((int2)(3, 4)));
+// CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 4>
void vector_literals_valid() {
- int4 a_1_1_1_1 = (int4)(1,2,3,4);
- int4 a_2_1_1 = (int4)((int2)(1,2),3,4);
- int4 a_1_2_1 = (int4)(1,(int2)(2,3),4);
- int4 a_1_1_2 = (int4)(1,2,(int2)(3,4));
- int4 a_2_2 = (int4)((int2)(1,2),(int2)(3,4));
- int4 a_3_1 = (int4)((int3)(1,2,3),4);
- int4 a_1_3 = (int4)(1,(int3)(2,3,4));
+ //CHECK: insertelement <4 x i32> <i32 1, i32 2, i32 undef, i32 undef>, i32 %{{.+}}, i32 2
+ //CHECK: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 3
+ int4 a_1_1_1_1 = (int4)(1, 2, c1.s2, c2.s3);
+
+ //CHECK: store <2 x i32> <i32 1, i32 2>, <2 x i32>*
+ //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
+ //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
+ //CHECK: insertelement <4 x i32> %{{.+}}, i32 3, i32 2
+ //CHECK: insertelement <4 x i32> %{{.+}}, i32 4, i32 3
+ int4 a_2_1_1 = (int4)((int2)(1, 2), 3, 4);
+
+ //CHECK: store <2 x i32> <i32 2, i32 3>, <2 x i32>*
+ //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
+ //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>
+ //CHECK: insertelement <4 x i32> %{{.+}}, i32 4, i32 3
+ int4 a_1_2_1 = (int4)(1, (int2)(2, 3), 4);
+
+ //CHECK: store <2 x i32> <i32 3, i32 4>, <2 x i32>*
+ //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
+ //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>
+ int4 a_1_1_2 = (int4)(1, 2, (int2)(3, 4));
+
+ //CHECK: store <2 x i32> <i32 1, i32 2>, <2 x i32>*
+ //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
+ //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
+ //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>
+ int4 a_2_2 = (int4)((int2)(1, 2), (int2)(3));
+
+ //CHECK: store <4 x i32> <i32 2, i32 3, i32 4, i32 undef>, <4 x i32>*
+ //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> undef, <3 x i32> <i32 0, i32 1, i32 2>
+ //CHECK: shufflevector <3 x i32> %{{.+}}, <3 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 undef>
+ //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>
+ int4 a_1_3 = (int4)(1, (int3)(2, 3, 4));
+
+ //CHECK: store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %a
int4 a = (int4)(1);
- int8 b = (int8)(1,2,a.xy,a);
- float4 V2 = (float4) (1);
-}
+ //CHECK: load <4 x i32>, <4 x i32>* %a, align 16
+ //CHECK: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> undef, <2 x i32> <i32 0, i32 1>
+ //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <8 x i32> <i32 0, i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
+ //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>
+ //CHECK: load <4 x i32>, <4 x i32>* %a, align 16
+ //CHECK: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
+ //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>
+ int8 b = (int8)(1, 2, a.xy, a);
+ //CHECK: store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, <4 x float>* %V2
+ float4 V2 = (float4)(1);
+}