summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenOpenCL
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2011-10-27 19:19:51 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2011-10-27 19:19:51 +0000
commit95fd2ca69f21f715d846d45178b1e57a76ee76ec (patch)
treeab7a79322e9947d7cfc773f730c155132a48ffb2 /clang/test/CodeGenOpenCL
parentf7d1e7be554530b28921a142ab83f97b4d80c4c9 (diff)
downloadbcm5719-llvm-95fd2ca69f21f715d846d45178b1e57a76ee76ec.tar.gz
bcm5719-llvm-95fd2ca69f21f715d846d45178b1e57a76ee76ec.zip
Annotate imprecise FP division with fpaccuracy metadata
The OpenCL single precision division operation is only required to be accurate to 2.5ulp. Annotate the fdiv instruction with metadata which signals to the backend that an imprecise divide instruction may be used. llvm-svn: 143136
Diffstat (limited to 'clang/test/CodeGenOpenCL')
-rw-r--r--clang/test/CodeGenOpenCL/fpaccuracy.cl25
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/test/CodeGenOpenCL/fpaccuracy.cl b/clang/test/CodeGenOpenCL/fpaccuracy.cl
new file mode 100644
index 00000000000..47fca696f9a
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/fpaccuracy.cl
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+
+float spscalardiv(float a, float b) {
+ // CHECK: @spscalardiv
+ // CHECK: fdiv{{.*}}, !fpaccuracy ![[MD:[0-9]+]]
+ return a / b;
+}
+
+float4 spvectordiv(float4 a, float4 b) {
+ // CHECK: @spvectordiv
+ // CHECK: fdiv{{.*}}, !fpaccuracy ![[MD]]
+ return a / b;
+}
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+double dpscalardiv(double a, double b) {
+ // CHECK: @dpscalardiv
+ // CHECK-NOT: !fpaccuracy
+ return a / b;
+}
+
+// CHECK: ![[MD]] = metadata !{i{{[0-9]+}} 5, i{{[0-9]+}} 2}
OpenPOWER on IntegriCloud