summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorAnastasia Stulova <anastasia.stulova@arm.com>2015-10-05 11:27:41 +0000
committerAnastasia Stulova <anastasia.stulova@arm.com>2015-10-05 11:27:41 +0000
commitb02e7835c569401d3359bf1d9f6b7eb5c979d228 (patch)
tree3f663a9d872ef489599ad00b0a8ce887b600fdc3 /clang/test
parent199e5232b3f57d007bf13d803bd2bf1260e71072 (diff)
downloadbcm5719-llvm-b02e7835c569401d3359bf1d9f6b7eb5c979d228.tar.gz
bcm5719-llvm-b02e7835c569401d3359bf1d9f6b7eb5c979d228.zip
[OpenCL] Fix casting a true boolean to an integer vector.
OpenCL v1.1 s6.2.2: for the boolean value true, every bit in the result vector should be set. This change treats the i1 value as signed for the purposes of performing the cast to integer, and therefore sign extend into the result. Patch by Neil Hickey! http://reviews.llvm.org/D13349 llvm-svn: 249301
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGenOpenCL/bool_cast.cl27
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/test/CodeGenOpenCL/bool_cast.cl b/clang/test/CodeGenOpenCL/bool_cast.cl
new file mode 100644
index 00000000000..d63431b1b7c
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/bool_cast.cl
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
+
+typedef unsigned char uchar4 __attribute((ext_vector_type(4)));
+typedef unsigned int int4 __attribute((ext_vector_type(4)));
+
+void kernel ker() {
+ bool t = true;
+ int4 vec4 = (int4)t;
+// CHECK: {{%.*}} = load i8, i8* %t, align 1
+// CHECK: {{%.*}} = trunc i8 {{%.*}} to i1
+// CHECK: {{%.*}} = sext i1 {{%.*}} to i32
+// CHECK: {{%.*}} = insertelement <4 x i32> undef, i32 {{%.*}}, i32 0
+// CHECK: {{%.*}} = shufflevector <4 x i32> {{%.*}}, <4 x i32> undef, <4 x i32> zeroinitializer
+// CHECK: store <4 x i32> {{%.*}}, <4 x i32>* %vec4, align 16
+ int i = (int)t;
+// CHECK: {{%.*}} = load i8, i8* %t, align 1
+// CHECK: {{%.*}} = trunc i8 {{%.*}} to i1
+// CHECK: {{%.*}} = zext i1 {{%.*}} to i32
+// CHECK: store i32 {{%.*}}, i32* %i, align 4
+
+ uchar4 vc;
+ vc = (uchar4)true;
+// CHECK: store <4 x i8> <i8 -1, i8 -1, i8 -1, i8 -1>, <4 x i8>* %vc, align 4
+ unsigned char c;
+ c = (unsigned char)true;
+// CHECK: store i8 1, i8* %c, align 1
+}
OpenPOWER on IntegriCloud