englefly commented on code in PR #10472:
URL: https://github.com/apache/doris/pull/10472#discussion_r909111109


##########
be/src/util/simd/bits.h:
##########
@@ -59,10 +59,28 @@ inline uint32_t bytes32_mask_to_bits32_mask(const bool* 
data) {
     return bytes32_mask_to_bits32_mask(reinterpret_cast<const uint8_t*>(data));
 }
 
-// compiler will make this SIMD automatically
 inline size_t count_zero_num(const int8_t* __restrict data, size_t size) {
     size_t num = 0;
     const int8_t* end = data + size;
+#if defined(__SSE2__) && defined(__POPCNT__)
+    const __m128i zero16 = _mm_setzero_si128();
+    const int8_t* end64 = data + (size / 64 * 64);
+
+    for (; data < end64; data += 64) {
+        num += __builtin_popcountll(
+                static_cast<uint64_t>(_mm_movemask_epi8(_mm_cmpeq_epi8(

Review Comment:
   According to my test, it gives wrong answer.
   I checked the intel docs for `_mm_slli_epi16`. Maybe the above codes need 
more intrinsics work together.
   
   Here is the spec for `_mm_slli_epi16`:
   ```
   FOR j := 0 to 7
        i := j*16
        IF imm8[7:0] > 15
                dst[i+15:i] := 0
        ELSE
                dst[i+15:i] := ZeroExtend16(a[i+15:i] << imm8[7:0])
        FI
   ENDFOR
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to