diff options
author | aneporada <aneporada@ydb.tech> | 2022-12-13 12:05:19 +0300 |
---|---|---|
committer | aneporada <aneporada@ydb.tech> | 2022-12-13 12:05:19 +0300 |
commit | d03c8226fc53c73dc64292d05366de418d8fb52a (patch) | |
tree | cab2698ca43cbd8c07ae7f49b071fd4f2f9cf1d5 | |
parent | 2f75779388bb5f5a7fc534fbb62f6fd34f6e1387 (diff) | |
download | ydb-d03c8226fc53c73dc64292d05366de418d8fb52a.tar.gz |
Optimize sparse bitmap operations (bitmap values should be either 0 or 1, all other values are forbidden and will lead to UB)
-rw-r--r-- | ydb/library/yql/minikql/comp_nodes/mkql_bit_utils.h | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/ydb/library/yql/minikql/comp_nodes/mkql_bit_utils.h b/ydb/library/yql/minikql/comp_nodes/mkql_bit_utils.h index edb3a7f8c4..f952d9f2b0 100644 --- a/ydb/library/yql/minikql/comp_nodes/mkql_bit_utils.h +++ b/ydb/library/yql/minikql/comp_nodes/mkql_bit_utils.h @@ -65,7 +65,7 @@ inline size_t GetSparseBitmapPopCount(const ui8* src, size_t len) { // auto-vectorization is performed here size_t result = 0; while (len--) { - result += *src++ & ui8(1); + result += *src++; } return result; } @@ -115,31 +115,31 @@ inline void CompressSparseBitmapNegate(ui8* dst, const ui8* srcSparse, size_t le inline void NegateSparseBitmap(ui8* dst, const ui8* src, size_t len) { while (len--) { - *dst++ = ~(*src++) & ui8(1); + *dst++ = *src++ ^ ui8(1); } } inline void XorSparseBitmapScalar(ui8* dst, ui8 value, const ui8* src, size_t len) { while (len--) { - *dst++ = (*src++ ^ value) & ui8(1); + *dst++ = *src++ ^ value; } } inline void XorSparseBitmaps(ui8* dst, const ui8* src1, const ui8* src2, size_t len) { while (len--) { - *dst++ = (*src1++ ^ *src2++) & ui8(1); + *dst++ = *src1++ ^ *src2++; } } inline void AndSparseBitmaps(ui8* dst, const ui8* src1, const ui8* src2, size_t len) { while (len--) { - *dst++ = (*src1++ & *src2++) & ui8(1); + *dst++ = *src1++ & *src2++; } } inline void OrSparseBitmaps(ui8* dst, const ui8* src1, const ui8* src2, size_t len) { while (len--) { - *dst++ = (*src1++ | *src2++) & ui8(1); + *dst++ = *src1++ | *src2++; } } @@ -186,8 +186,7 @@ template<typename T> inline T* CompressArray(const T* src, const ui8* sparseBitmap, T* dst, size_t count) { while (count--) { *dst = *src++; - dst += *sparseBitmap & 1u; - sparseBitmap++; + dst += *sparseBitmap++; } return dst; } |