kou commented on code in PR #13376:
URL: https://github.com/apache/arrow/pull/13376#discussion_r896152027


##########
cpp/src/arrow/util/bit_util.h:
##########
@@ -67,7 +67,14 @@ static constexpr uint8_t kBytePopcount[] = {
     5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 
4, 5, 5, 6,
     4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};
 
-static inline uint64_t PopCount(uint64_t bitmap) { return 
ARROW_POPCOUNT64(bitmap); }
+static inline uint64_t PopCount(uint64_t bitmap) {
+#if defined(_MSC_VER) && !defined(_M_AMD64) && !defined(_M_X64) 
+  const uint32_t* p = reinterpret_cast<const uint32_t*>((void*)(&bitmap));
+  return ARROW_POPCOUNT32(*p) + ARROW_POPCOUNT32(*(p + 1));

Review Comment:
   I'm not sure which is better for performance but it seems that we can use 
bit operations to split `uint64_t` value to `uint32_t` values:
   
   ```c++
     return ARROW_POPCOUNT32((bitmap >> 32) & UINT32_MAX) +
            ARROW_POPCOUNT32(bitmap & UINT32_MAX);
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to