From e4cf70cad7577a0bb0b47c5f834dc5d5ad9140f2 Mon Sep 17 00:00:00 2001 From: Luo Xionghu Date: Thu, 15 Jan 2015 19:39:35 +0800 Subject: fix the wrong implementation of popcount. add disassembly for cbit. Signed-off-by: Luo Xionghu Reviewed-by: Zhigang Gong --- 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 162d459f..4822de38 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 992727f6..28b9c208 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); -- cgit v1.2.1