[Beignet] [PATCH] fix the wrong implementation of popcount.

xionghu.luo at intel.com xionghu.luo at intel.com
Thu Jan 15 03:39:35 PST 2015


From: Luo Xionghu <xionghu.luo at intel.com>

add disassembly for cbit.

Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
---
 backend/src/backend/gen/gen_mesa_disasm.c   |  1 +
 backend/src/libocl/tmpl/ocl_integer.tmpl.cl | 10 +++-------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/backend/src/backend/gen/gen_mesa_disasm.c b/backend/src/backend/gen/gen_mesa_disasm.c
index 162d459..4822de3 100644
--- a/backend/src/backend/gen/gen_mesa_disasm.c
+++ b/backend/src/backend/gen/gen_mesa_disasm.c
@@ -67,6 +67,7 @@ static const struct {
   [GEN_OPCODE_LZD] = { .name = "lzd", .nsrc = 1, .ndst = 1 },
   [GEN_OPCODE_FBH] = { .name = "fbh", .nsrc = 1, .ndst = 1 },
   [GEN_OPCODE_FBL] = { .name = "fbl", .nsrc = 1, .ndst = 1 },
+  [GEN_OPCODE_CBIT] = { .name = "cbit", .nsrc = 1, .ndst = 1 },
   [GEN_OPCODE_F16TO32] = { .name = "f16to32", .nsrc = 1, .ndst = 1 },
   [GEN_OPCODE_F32TO16] = { .name = "f32to16", .nsrc = 1, .ndst = 1 },
 
diff --git a/backend/src/libocl/tmpl/ocl_integer.tmpl.cl b/backend/src/libocl/tmpl/ocl_integer.tmpl.cl
index 992727f..28b9c20 100644
--- a/backend/src/libocl/tmpl/ocl_integer.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_integer.tmpl.cl
@@ -87,15 +87,11 @@ OVERLOADABLE ulong clz(ulong x) {
   return v;
 }
 
-OVERLOADABLE char popcount(char x) {
-  return x == 0 ? 0 : x < 0?__gen_ocl_cbit(x) - 24 : __gen_ocl_cbit(x);
-}
-OVERLOADABLE short popcount(short x) {
-  return x == 0 ? 0 : x < 0?__gen_ocl_cbit(x) - 16 : __gen_ocl_cbit(x);
-}
 #define SDEF(TYPE)        \
-OVERLOADABLE TYPE popcount(TYPE x){ return x == 0? 0:__gen_ocl_cbit(x);}
+OVERLOADABLE TYPE popcount(TYPE x){ return __gen_ocl_cbit(x);}
+SDEF(char);
 SDEF(uchar);
+SDEF(short);
 SDEF(ushort);
 SDEF(int);
 SDEF(uint);
-- 
1.9.1



More information about the Beignet mailing list