summaryrefslogtreecommitdiff
path: root/test/CodeGenOpenCL
diff options
context:
space:
mode:
authorNeil Hickey <neil.hickey@arm.com>2016-11-14 11:15:51 +0000
committerNeil Hickey <neil.hickey@arm.com>2016-11-14 11:15:51 +0000
commite5fa1968fed56e039447a71ed42438b1b77381f0 (patch)
tree0e939a575b013f5372272ff99e5647a8af4dc34b /test/CodeGenOpenCL
parentd6168b6ed57fe78bf42f57509d73bde2680105b5 (diff)
downloadclang-e5fa1968fed56e039447a71ed42438b1b77381f0.tar.gz
Improve handling of floating point literals in OpenCL to only use double precision if the target supports fp64.
This change makes sure single-precision floating point types are used if the cl_fp64 extension is not supported by the target. Also removed the check to see whether the OpenCL version is >= 1.2, as this has been incorporated into the extension setting code. Differential Revision: https://reviews.llvm.org/D24235 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286815 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenOpenCL')
-rw-r--r--test/CodeGenOpenCL/fpmath.cl13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/CodeGenOpenCL/fpmath.cl b/test/CodeGenOpenCL/fpmath.cl
index 780c95f6fb..c23e03b3ff 100644
--- a/test/CodeGenOpenCL/fpmath.cl
+++ b/test/CodeGenOpenCL/fpmath.cl
@@ -1,5 +1,6 @@
// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck --check-prefix=CHECK --check-prefix=NODIVOPT %s
// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-fp32-correctly-rounded-divide-sqrt | FileCheck --check-prefix=CHECK --check-prefix=DIVOPT %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -DNOFP64 -cl-std=CL1.1 -triple r600-unknown-unknown -target-cpu r600 -pedantic | FileCheck --check-prefix=CHECK-DBL %s
typedef __attribute__(( ext_vector_type(4) )) float float4;
@@ -21,14 +22,26 @@ float4 spvectordiv(float4 a, float4 b) {
return a / b;
}
+void printf(constant char* fmt, ...);
+
+#ifndef NOFP64
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+void testdbllit(long *val) {
+ // CHECK-DBL: float 2.000000e+01
+ // CHECK: double 2.000000e+01
+ printf("%f", 20.0);
+}
+#ifndef NOFP64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
double dpscalardiv(double a, double b) {
// CHECK: @dpscalardiv
// CHECK: #[[ATTR]]
// CHECK-NOT: !fpmath
return a / b;
}
+#endif
// CHECK: attributes #[[ATTR]] = {
// NODIVOPT: "correctly-rounded-divide-sqrt-fp-math"="false"