Skip to content

Commit 9a5d9d8

Browse files
committed
original
Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent df86041 commit 9a5d9d8

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

vortex-buffer/src/bit/count_ones.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ fn mask_byte(byte: u8, bit_offset: usize, bit_len: usize) -> u8 {
7070
fn count_ones_aligned(bytes: &[u8]) -> usize {
7171
#[cfg(target_arch = "x86_64")]
7272
{
73-
if is_x86_feature_detected!("avx512f")
73+
if bytes.len() >= 64
74+
&& is_x86_feature_detected!("avx512f")
7475
&& is_x86_feature_detected!("avx512vpopcntdq")
75-
&& bytes.len() >= 64
7676
{
7777
// SAFETY: Runtime detection guarantees the required target features.
7878
return unsafe { count_ones_aligned_avx512(bytes) };
7979
}
8080

81-
if is_x86_feature_detected!("avx2") && bytes.len() >= 32 {
81+
if bytes.len() >= 32 && is_x86_feature_detected!("avx2") {
8282
// SAFETY: Runtime detection guarantees the required target features.
8383
return unsafe { count_ones_aligned_avx2(bytes) };
8484
}

0 commit comments

Comments
 (0)