| 235 | }; |
| 236 | |
| 237 | inline uint64_t ExtractBitsSoftware(uint64_t bitmap, uint64_t select_bitmap) { |
| 238 | // A software emulation of _pext_u64 |
| 239 | |
| 240 | // These checks should be inline and are likely to be common cases. |
| 241 | if (select_bitmap == ~uint64_t{0}) { |
| 242 | return bitmap; |
| 243 | } else if (select_bitmap == 0) { |
| 244 | return 0; |
| 245 | } |
| 246 | |
| 247 | // Fallback to lookup table method |
| 248 | uint64_t bit_value = 0; |
| 249 | int bit_len = 0; |
| 250 | constexpr uint8_t kLookupMask = (1U << kLookupBits) - 1; |
| 251 | while (select_bitmap != 0) { |
| 252 | const auto mask_len = std::popcount(select_bitmap & kLookupMask); |
| 253 | const uint64_t value = kPextTable[select_bitmap & kLookupMask][bitmap & kLookupMask]; |
| 254 | bit_value |= (value << bit_len); |
| 255 | bit_len += mask_len; |
| 256 | bitmap >>= kLookupBits; |
| 257 | select_bitmap >>= kLookupBits; |
| 258 | } |
| 259 | return bit_value; |
| 260 | } |
| 261 | |
| 262 | #ifdef ARROW_HAVE_BMI2 |
| 263 |
no outgoing calls