this patch passes following piglit test cases: piglit/framework/../bin/cl-program-tester generated_tests/cl/builtin/int/builtin-ulong-clz-1.0.generated.cl piglit/framework/../bin/cl-program-tester generated_tests/cl/builtin/int/builtin-long-clz-1.0.generated.cl
Signed-off-by: Homer Hsing <homer.x...@intel.com> --- backend/src/ocl_stdlib.tmpl.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h index 0a6a937..f209b52 100644 --- a/backend/src/ocl_stdlib.tmpl.h +++ b/backend/src/ocl_stdlib.tmpl.h @@ -313,11 +313,27 @@ INLINE_OVERLOADABLE uint clz(uint x) { } INLINE_OVERLOADABLE long clz(long x) { - return 0; + if (x < 0) + return 0; + if (x == 0) + return 64; + union { int i[2]; long x; } u; + u.x = x; + uint v = clz(u.i[1]); + if(v == 32) + v += clz(u.i[0]); + return v; } INLINE_OVERLOADABLE ulong clz(ulong x) { - return 0; + if (x == 0) + return 64; + union { uint i[2]; ulong x; } u; + u.x = x; + uint v = clz(u.i[1]); + if(v == 32) + v += clz(u.i[0]); + return v; } OVERLOADABLE int __gen_ocl_mul_hi(int x, int y); -- 1.8.1.2 _______________________________________________ Beignet mailing list Beignet@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/beignet