From 2ef5ec6b2bc0c0bcc5b7b09004de4038fe1f901e Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 10 Jul 2015 13:37:07 +0000 Subject: 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 --- libclc/generic/include/clc/math/sqrt.h | 9 +++------ libclc/generic/include/clc/math/sqrt.inc | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 libclc/generic/include/clc/math/sqrt.inc (limited to 'libclc/generic/include/clc') 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 +#define __CLC_BODY +#include +#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); -- cgit v1.2.3