summaryrefslogtreecommitdiffstats
path: root/libclc/generic/include/clc
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2015-07-10 13:37:07 +0000
committerTom Stellard <thomas.stellard@amd.com>2015-07-10 13:37:07 +0000
commit2ef5ec6b2bc0c0bcc5b7b09004de4038fe1f901e (patch)
tree35901313c27b03586a6dbfcf4337cdbcd51352ad /libclc/generic/include/clc
parent0e4152e391177de27feb461611d4045f22cb57c1 (diff)
downloadbcm5719-llvm-2ef5ec6b2bc0c0bcc5b7b09004de4038fe1f901e.tar.gz
bcm5719-llvm-2ef5ec6b2bc0c0bcc5b7b09004de4038fe1f901e.zip
Fix implementation of sqrt v2
Passing values less than 0 to the llvm.sqrt() intrinsic results in undefined behavior, so we need to check the input and return NaN if is is less than 0. v2: - Fix build failures. llvm-svn: 241906
Diffstat (limited to 'libclc/generic/include/clc')
-rw-r--r--libclc/generic/include/clc/math/sqrt.h9
-rw-r--r--libclc/generic/include/clc/math/sqrt.inc1
2 files changed, 4 insertions, 6 deletions
diff --git a/libclc/generic/include/clc/math/sqrt.h b/libclc/generic/include/clc/math/sqrt.h
index f69de847e62..ccde9748adb 100644
--- a/libclc/generic/include/clc/math/sqrt.h
+++ b/libclc/generic/include/clc/math/sqrt.h
@@ -1,6 +1,3 @@
-#undef sqrt
-#define sqrt __clc_sqrt
-
-#define __CLC_FUNCTION __clc_sqrt
-#define __CLC_INTRINSIC "llvm.sqrt"
-#include <clc/math/unary_intrin.inc>
+#define __CLC_BODY <clc/math/sqrt.inc>
+#include <clc/math/gentype.inc>
+#undef __CLC_BODY
diff --git a/libclc/generic/include/clc/math/sqrt.inc b/libclc/generic/include/clc/math/sqrt.inc
new file mode 100644
index 00000000000..f629fac761b
--- /dev/null
+++ b/libclc/generic/include/clc/math/sqrt.inc
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE sqrt(__CLC_GENTYPE a);
OpenPOWER on IntegriCloud