Skip to content

Commit

Permalink
Fix assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratyush committed Jan 12, 2022
1 parent f09c728 commit 565fad4
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions ff/src/fields/models/fp/montgomery_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@ pub trait MontConfig<const N: usize>: 'static + Sync + Send + Sized {
#[cfg(use_asm)]
#[allow(unsafe_code, unused_mut)]
// Tentatively avoid using assembly for `N == 1`.
#[rustfmt::skip]
match N {
2 => ark_ff_asm::x86_64_asm_mul!(2, (a.0).0, (b.0).0),
3 => ark_ff_asm::x86_64_asm_mul!(3, (a.0).0, (b.0).0),
4 => ark_ff_asm::x86_64_asm_mul!(4, (a.0).0, (b.0).0),
5 => ark_ff_asm::x86_64_asm_mul!(5, (a.0).0, (b.0).0),
6 => ark_ff_asm::x86_64_asm_mul!(6, (a.0).0, (b.0).0),
2 => { ark_ff_asm::x86_64_asm_mul!(2, (a.0).0, (b.0).0); },
3 => { ark_ff_asm::x86_64_asm_mul!(3, (a.0).0, (b.0).0); },
4 => { ark_ff_asm::x86_64_asm_mul!(4, (a.0).0, (b.0).0); },
5 => { ark_ff_asm::x86_64_asm_mul!(5, (a.0).0, (b.0).0); },
6 => { ark_ff_asm::x86_64_asm_mul!(6, (a.0).0, (b.0).0); },
};
} else {
let mut r = [0u64; N];
Expand Down Expand Up @@ -140,12 +141,13 @@ pub trait MontConfig<const N: usize>: 'static + Sync + Send + Sized {
let no_carry: bool = !(first_bit_set || all_bits_set);

if N <= 6 && no_carry {
#[rustfmt::skip]
match N {
2 => ark_ff_asm::x86_64_asm_square!(2, (a.0).0),
3 => ark_ff_asm::x86_64_asm_square!(3, (a.0).0),
4 => ark_ff_asm::x86_64_asm_square!(4, (a.0).0),
5 => ark_ff_asm::x86_64_asm_square!(5, (a.0).0),
6 => ark_ff_asm::x86_64_asm_square!(6, (a.0).0),
2 => { ark_ff_asm::x86_64_asm_square!(2, (a.0).0); },
3 => { ark_ff_asm::x86_64_asm_square!(3, (a.0).0); },
4 => { ark_ff_asm::x86_64_asm_square!(4, (a.0).0); },
5 => { ark_ff_asm::x86_64_asm_square!(5, (a.0).0); },
6 => { ark_ff_asm::x86_64_asm_square!(6, (a.0).0); },
};
a.subtract_modulus();
return;
Expand Down

0 comments on commit 565fad4

Please sign in to comment.