alamb commented on code in PR #11322:
URL: https://github.com/apache/arrow-rs/pull/11322#discussion_r4271497618


##########
arrow-buffer/src/util/bit_util.rs:
##########
@@ -64,6 +73,29 @@ pub fn compress(value: u64, mask: u64) -> u64 {
 
     #[cfg(not(all(target_arch = "x86_64", target_feature = "bmi2")))]
     {
+        compress_portable(value, mask)
+    }
+}
+
+/// [`compress`] without `pext`, by the number of kept bits `k`:
+///
+/// * `k <= 2`: the two lowest kept bits, tested directly
+/// * `k <= 16`: one step per kept bit
+/// * `k >= 62`: `value` with its at most two dropped bits removed
+/// * otherwise [`compress_bytes`]
+///
+/// The two ends need no loop, so no loop exit to mispredict when `k`
+/// varies from word to word.
+// Always: called once a word, so a call would cost more than a sparse word
+#[cfg(any(test, not(all(target_arch = "x86_64", target_feature = "bmi2"))))]
+#[inline(always)]
+fn compress_portable(value: u64, mask: u64) -> u64 {
+    let kept = mask.count_ones();

Review Comment:
   Oh boy, we are getting fancy now



-- 
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