I don't know the exact reason ... I hope someone can dig the reason in the future ...
-----Original Message----- From: Zhigang Gong [mailto:[email protected]] Sent: Wednesday, September 4, 2013 10:51 AM To: Xing, Homer Cc: [email protected] Subject: Re: [Beignet] [PATCH] fix 64-bit "clz" if parameter is "long4" or "ulong4" Homer, Could you tell a little bit more about why the previous version couldn't work? Thanks. On Wed, Sep 04, 2013 at 10:33:39AM +0800, Homer Hsing wrote: > > Signed-off-by: Homer Hsing <[email protected]> > --- > 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 > > _______________________________________________ > Beignet mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/beignet _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
