================
@@ -0,0 +1,38 @@
+#include <clc/clcmacro.h>
+#include <clc/internal/clc.h>
+#include <clc/relational/clc_isnan.h>
+
+#define CLC_SIGN(TYPE, F)                                                      
\
+  _CLC_DEF _CLC_OVERLOAD TYPE __clc_sign(TYPE x) {                             
\
+    if (__clc_isnan(x)) {                                                      
\
+      return 0.0F;                                                             
\
+    }                                                                          
\
+    if (x > 0.0F) {                                                            
\
+      return 1.0F;                                                             
\
+    }                                                                          
\
+    if (x < 0.0F) {                                                            
\
+      return -1.0F;                                                            
\
+    }                                                                          
\
+    return x; /* -0.0 or +0.0 */                                               
\
----------------
frasercrmck wrote:

OpenCL sign returns 1.0 if x > 0 and -1.0 if x < 0. copysign also returns NaN 
for `copysign(NaN, ...)`, whereas sign should return 0.0.

https://github.com/llvm/llvm-project/pull/115699
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to