LGTM, thanks.

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Homer Hsing
Sent: Thursday, November 07, 2013 2:32 PM
To: [email protected]
Subject: [Beignet] [PATCH] fix builtin function "copysign"

using better algorithm

Signed-off-by: Homer Hsing <[email protected]>
---
 backend/src/ocl_stdlib.tmpl.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h 
index 3df893a..fdccf83 100644
--- a/backend/src/ocl_stdlib.tmpl.h
+++ b/backend/src/ocl_stdlib.tmpl.h
@@ -1452,7 +1452,11 @@ INLINE_OVERLOADABLE float __gen_ocl_internal_atanh(float 
x) {
   return 0.5f * native_sqrt((1 + x) / (1 - x));  }  INLINE_OVERLOADABLE float 
__gen_ocl_internal_copysign(float x, float y) {
-  return x * y < 0 ? -x : x;
+  union { unsigned u; float f; } ux, uy;  ux.f = x;  uy.f = y;  ux.u = 
+ (ux.u & 0x7fffffff) | (uy.u & 0x80000000u);  return ux.f;
 }
 INLINE_OVERLOADABLE float __gen_ocl_internal_erf(float x) {
   return M_2_SQRTPI_F * (x - __gen_ocl_pow(x, 3) / 3 + __gen_ocl_pow(x, 5) / 
10 - __gen_ocl_pow(x, 7) / 42 + __gen_ocl_pow(x, 9) / 216);
--
1.8.3.2

_______________________________________________
Beignet mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/beignet
_______________________________________________
Beignet mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/beignet

Reply via email to