Add rsqrt builtin. Based on patch by Cassie Epps!
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 21 Aug 2012 10:48:35 +0000 (10:48 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 21 Aug 2012 10:48:35 +0000 (10:48 +0000)
llvm-svn: 162274

libclc/generic/include/clc/clc.h
libclc/generic/include/clc/math/rsqrt.h [new file with mode: 0644]
libclc/test/rsqrt.cl [new file with mode: 0644]

index 4f49760..565b505 100644 (file)
@@ -53,6 +53,7 @@
 #include <clc/math/native_log2.h>
 #include <clc/math/native_sin.h>
 #include <clc/math/native_sqrt.h>
+#include <clc/math/rsqrt.h>
 
 /* 6.11.3 Integer Functions */
 #include <clc/integer/abs.h>
diff --git a/libclc/generic/include/clc/math/rsqrt.h b/libclc/generic/include/clc/math/rsqrt.h
new file mode 100644 (file)
index 0000000..8fd2cbf
--- /dev/null
@@ -0,0 +1 @@
+#define rsqrt(x) (1.f/sqrt(x))\r
diff --git a/libclc/test/rsqrt.cl b/libclc/test/rsqrt.cl
new file mode 100644 (file)
index 0000000..13ad216
--- /dev/null
@@ -0,0 +1,6 @@
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+__kernel void foo(float4 *x, double4 *y) {
+  x[1] = rsqrt(x[0]);
+  y[1] = rsqrt(y[0]);
+}