[libclc] r217045 - Fix implementation of copysign

Tom Stellard thomas.stellard at amd.com
Wed Sep 3 08:55:38 PDT 2014


Author: tstellar
Date: Wed Sep  3 10:55:38 2014
New Revision: 217045

URL: http://llvm.org/viewvc/llvm-project?rev=217045&view=rev
Log:
Fix implementation of copysign

This was previously implemented with a macro and we were using
__builtin_copysign(), which takes double inputs for the float
version of copysign().

Reviewed-and-Tested-by: Aaron Watry <awatry at gmail.com>

Added:
    libclc/trunk/generic/include/clc/math/copysign.inc
    libclc/trunk/generic/lib/math/copysign.cl
Modified:
    libclc/trunk/generic/include/clc/math/copysign.h
    libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/math/copysign.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/copysign.h?rev=217045&r1=217044&r2=217045&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/math/copysign.h (original)
+++ libclc/trunk/generic/include/clc/math/copysign.h Wed Sep  3 10:55:38 2014
@@ -1 +1,2 @@
-#define copysign(x, y) __builtin_copysign(x, y)
+#define __CLC_BODY <clc/math/copysign.inc>
+#include <clc/math/gentype.inc>

Added: libclc/trunk/generic/include/clc/math/copysign.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/copysign.inc?rev=217045&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/math/copysign.inc (added)
+++ libclc/trunk/generic/include/clc/math/copysign.inc Wed Sep  3 10:55:38 2014
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE copysign(__CLC_GENTYPE a, __CLC_GENTYPE b);

Modified: libclc/trunk/generic/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=217045&r1=217044&r2=217045&view=diff
==============================================================================
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Sep  3 10:55:38 2014
@@ -31,6 +31,7 @@ integer/sub_sat_impl.ll
 integer/upsample.cl
 math/atan.cl
 math/atan2.cl
+math/copysign.cl
 math/cos.cl
 math/exp.cl
 math/exp10.cl

Added: libclc/trunk/generic/lib/math/copysign.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/copysign.cl?rev=217045&view=auto
==============================================================================
--- libclc/trunk/generic/lib/math/copysign.cl (added)
+++ libclc/trunk/generic/lib/math/copysign.cl Wed Sep  3 10:55:38 2014
@@ -0,0 +1,12 @@
+#include <clc/clc.h>
+#include "../clcmacro.h"
+
+_CLC_DEFINE_BINARY_BUILTIN(float, copysign, __builtin_copysignf, float, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_DEFINE_BINARY_BUILTIN(double, copysign, __builtin_copysign, double, double)
+
+#endif





More information about the cfe-commits mailing list