Skip to content

Commit

Permalink
fix: overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
eigmax committed Nov 28, 2023
1 parent 7e843d8 commit 4b4eae9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions algebraic/src/arch/x86_64/avx2_field_gl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl Avx2GoldilocksField {
/// A trick to suppress overflow. `as_slice` may return an element bigger than GL modular.
#[inline]
pub fn as_slice_reduced(&mut self) -> &[GoldilocksField] {
*self = Self::ZEROS + *self;
&self.0[..]
}
}
Expand All @@ -71,8 +72,6 @@ unsafe impl PackedField for Avx2GoldilocksField {
}
#[inline]
fn as_slice_mut(&mut self) -> &mut [GoldilocksField] {
// A trick to suppress overflow. `as_slice` may return a number bigger than GL modular.
*self = Self::ZEROS + *self;
&mut self.0[..]
}

Expand Down Expand Up @@ -471,7 +470,7 @@ unsafe fn reduce128(x: (__m256i, __m256i)) -> __m256i {
let lo1_s = sub_small_64s_64_s(lo0_s, hi_hi0);
let t1 = _mm256_mul_epu32(hi0, EPSILON);
let lo2_s = add_small_64s_64_s(lo1_s, t1);
let lo2 = shift(canonicalize_s(lo2_s));
let lo2 = shift(lo2_s);
lo2
}

Expand Down

0 comments on commit 4b4eae9

Please sign in to comment.