Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request 0xPolygonZero#1294 from matthiasgoergens/matthias/…
Browse files Browse the repository at this point in the history
…make-clippy-happy

Make clippy happy
  • Loading branch information
pgebheim authored Nov 16, 2023
2 parents eda7fd6 + f924270 commit 40d3c6d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions field/src/arch/x86_64/avx2_goldilocks_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ impl Default for Avx2GoldilocksField {

impl Div<GoldilocksField> for Avx2GoldilocksField {
type Output = Self;
#[allow(clippy::suspicious_arithmetic_impl)]
#[inline]
fn div(self, rhs: GoldilocksField) -> Self {
self * rhs.inverse()
}
}
impl DivAssign<GoldilocksField> for Avx2GoldilocksField {
#[allow(clippy::suspicious_op_assign_impl)]
#[inline]
fn div_assign(&mut self, rhs: GoldilocksField) {
*self *= rhs.inverse();
Expand Down Expand Up @@ -318,8 +320,7 @@ unsafe fn add_no_double_overflow_64_64s_s(x: __m256i, y_s: __m256i) -> __m256i {
let res_wrapped_s = _mm256_add_epi64(x, y_s);
let mask = _mm256_cmpgt_epi64(y_s, res_wrapped_s); // -1 if overflowed else 0.
let wrapback_amt = _mm256_srli_epi64::<32>(mask); // -FIELD_ORDER if overflowed else 0.
let res_s = _mm256_add_epi64(res_wrapped_s, wrapback_amt);
res_s
_mm256_add_epi64(res_wrapped_s, wrapback_amt)
}

#[inline]
Expand All @@ -337,8 +338,7 @@ unsafe fn sub(x: __m256i, y: __m256i) -> __m256i {
let mask = _mm256_cmpgt_epi64(y_s, x_s); // -1 if sub will underflow (y > x) else 0.
let wrapback_amt = _mm256_srli_epi64::<32>(mask); // -FIELD_ORDER if underflow else 0.
let res_wrapped = _mm256_sub_epi64(x_s, y_s);
let res = _mm256_sub_epi64(res_wrapped, wrapback_amt);
res
_mm256_sub_epi64(res_wrapped, wrapback_amt)
}

#[inline]
Expand Down Expand Up @@ -427,8 +427,7 @@ unsafe fn add_small_64s_64_s(x_s: __m256i, y: __m256i) -> __m256i {
let mask = _mm256_cmpgt_epi32(x_s, res_wrapped_s); // -1 if overflowed else 0.
// The mask contains 0xffffffff in the high 32 bits if wraparound occurred and 0 otherwise.
let wrapback_amt = _mm256_srli_epi64::<32>(mask); // -FIELD_ORDER if overflowed else 0.
let res_s = _mm256_add_epi64(res_wrapped_s, wrapback_amt);
res_s
_mm256_add_epi64(res_wrapped_s, wrapback_amt)
}

/// Goldilocks subtraction of a "small" number. `x_s` is pre-shifted by 2**63. `y` is assumed to be
Expand All @@ -444,8 +443,7 @@ unsafe fn sub_small_64s_64_s(x_s: __m256i, y: __m256i) -> __m256i {
let mask = _mm256_cmpgt_epi32(res_wrapped_s, x_s); // -1 if underflowed else 0.
// The mask contains 0xffffffff in the high 32 bits if wraparound occurred and 0 otherwise.
let wrapback_amt = _mm256_srli_epi64::<32>(mask); // -FIELD_ORDER if underflowed else 0.
let res_s = _mm256_sub_epi64(res_wrapped_s, wrapback_amt);
res_s
_mm256_sub_epi64(res_wrapped_s, wrapback_amt)
}

#[inline]
Expand All @@ -456,8 +454,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(lo2_s);
lo2
shift(lo2_s)
}

/// Multiply two integers modulo FIELD_ORDER.
Expand Down Expand Up @@ -628,6 +625,7 @@ mod tests {
}
}

#[allow(clippy::zero_prefixed_literal)]
#[test]
fn test_interleave() {
let in_a: [GoldilocksField; 4] = [
Expand Down

0 comments on commit 40d3c6d

Please sign in to comment.