Skip to content

Commit 76de5ba

Browse files
authored
fix unsafe warnings (#2757)
1 parent b7eb311 commit 76de5ba

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

bitpacker/src/filter_vec/avx2.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn u32_to_i32(val: u32) -> i32 {
1919
#[inline]
2020
unsafe fn u32_to_i32_avx2(vals_u32x8s: DataType) -> DataType {
2121
const HIGHEST_BIT_MASK: DataType = from_u32x8([HIGHEST_BIT; NUM_LANES]);
22-
op_xor(vals_u32x8s, HIGHEST_BIT_MASK)
22+
unsafe { op_xor(vals_u32x8s, HIGHEST_BIT_MASK) }
2323
}
2424

2525
pub fn filter_vec_in_place(range: RangeInclusive<u32>, offset: u32, output: &mut Vec<u32>) {
@@ -66,17 +66,19 @@ unsafe fn filter_vec_avx2_aux(
6666
]);
6767
const SHIFT: __m256i = from_u32x8([NUM_LANES as u32; NUM_LANES]);
6868
for _ in 0..num_words {
69-
let word = load_unaligned(input);
70-
let word = u32_to_i32_avx2(word);
71-
let keeper_bitset = compute_filter_bitset(word, range_simd.clone());
72-
let added_len = keeper_bitset.count_ones();
73-
let filtered_doc_ids = compact(ids, keeper_bitset);
74-
store_unaligned(output_tail as *mut __m256i, filtered_doc_ids);
75-
output_tail = output_tail.offset(added_len as isize);
76-
ids = op_add(ids, SHIFT);
77-
input = input.offset(1);
69+
unsafe {
70+
let word = load_unaligned(input);
71+
let word = u32_to_i32_avx2(word);
72+
let keeper_bitset = compute_filter_bitset(word, range_simd.clone());
73+
let added_len = keeper_bitset.count_ones();
74+
let filtered_doc_ids = compact(ids, keeper_bitset);
75+
store_unaligned(output_tail as *mut __m256i, filtered_doc_ids);
76+
output_tail = output_tail.offset(added_len as isize);
77+
ids = op_add(ids, SHIFT);
78+
input = input.offset(1);
79+
}
7880
}
79-
output_tail.offset_from(output) as usize
81+
unsafe { output_tail.offset_from(output) as usize }
8082
}
8183

8284
#[inline]
@@ -92,8 +94,7 @@ unsafe fn compute_filter_bitset(val: __m256i, range: std::ops::RangeInclusive<__
9294
let too_low = op_greater(*range.start(), val);
9395
let too_high = op_greater(val, *range.end());
9496
let inside = op_or(too_low, too_high);
95-
255 - std::arch::x86_64::_mm256_movemask_ps(std::mem::transmute::<DataType, __m256>(inside))
96-
as u8
97+
255 - std::arch::x86_64::_mm256_movemask_ps(_mm256_castsi256_ps(inside)) as u8
9798
}
9899

99100
union U8x32 {

0 commit comments

Comments
 (0)