[Beignet] [PATCH] fix 64-bit "clz" if parameter is "long4" or "ulong4"

Homer Hsing homer.xing at intel.com
Tue Sep 3 19:33:39 PDT 2013


Signed-off-by: Homer Hsing <homer.xing at intel.com>
---
 backend/src/ocl_stdlib.tmpl.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h
index 2b470e5..72f7d76 100644
--- a/backend/src/ocl_stdlib.tmpl.h
+++ b/backend/src/ocl_stdlib.tmpl.h
@@ -318,12 +318,12 @@ INLINE_OVERLOADABLE uint clz(uint x) {
 }
 
 INLINE_OVERLOADABLE long clz(long x) {
-  if (x < 0)
-    return 0;
-  if (x == 0)
-    return 64;
   union { int i[2]; long x; } u;
   u.x = x;
+  if (u.i[1] & 0x80000000u)
+    return 0;
+  if (u.i[1] == 0 && u.i[0] == 0)
+    return 64;
   uint v = clz(u.i[1]);
   if(v == 32)
     v += clz(u.i[0]);
-- 
1.8.1.2



More information about the Beignet mailing list