Skip to content

Commit 855806b

Browse files
committed
apply cr comments
1 parent 7e8a009 commit 855806b

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

src/bitpacker4x.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ mod neon {
9898

9999
#[inline]
100100
unsafe fn right_shift_32<const N: i32>(el: DataType) -> DataType {
101+
const {
102+
assert!(N >= 0);
103+
assert!(N <= 32);
104+
}
105+
101106
// We unroll here because vshrq_n_u32 only accepts constants from 1 to 32.
102107
match N {
103108
0 => el,
@@ -132,14 +137,19 @@ mod neon {
132137
29 => vshrq_n_u32::<29>(el),
133138
30 => vshrq_n_u32::<30>(el),
134139
31 => vshrq_n_u32::<31>(el),
135-
32 => vshrq_n_u32::<32>(el),
140+
32 => vdupq_n_u32(0),
136141
_ => core::hint::unreachable_unchecked(),
137142
}
138143
}
139144

140145
#[inline]
141146
unsafe fn left_shift_32<const N: i32>(el: DataType) -> DataType {
142-
// We unroll here because vshlq_n_u32 only accepts constants from 1 to 32.
147+
const {
148+
assert!(N >= 0);
149+
assert!(N <= 32);
150+
}
151+
152+
// We unroll here because vshlq_n_u32 only accepts constants from 0 to 31.
143153
match N {
144154
0 => el,
145155
1 => vshlq_n_u32::<1>(el),
@@ -178,11 +188,7 @@ mod neon {
178188
}
179189
}
180190

181-
#[inline]
182-
unsafe fn op_or(left: DataType, right: DataType) -> DataType {
183-
// Bitwise OR of two vectors
184-
vorrq_u32(left, right)
185-
}
191+
use vorrq_u32 as op_or;
186192

187193
#[inline]
188194
unsafe fn op_and(left: DataType, right: DataType) -> DataType {

0 commit comments

Comments
 (0)