Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
optimize twice reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
ashWhiteHat committed Jan 21, 2022
1 parent 4886749 commit 4ffe4dc
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/bn256/fr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,21 @@ impl Fr {
"cmovc r10, r14",
"cmovc r11, r15",

"mov r12, r8",
"mov r13, r9",
"mov r14, r10",
"mov r15, r11",

"sub r12, qword ptr [{m_ptr} + 0]",
"sbb r13, qword ptr [{m_ptr} + 8]",
"sbb r14, qword ptr [{m_ptr} + 16]",
"sbb r15, qword ptr [{m_ptr} + 24]",

"cmovc r12, r8",
"cmovc r13, r9",
"cmovc r14, r10",
"cmovc r15, r11",

i_ptr = in(reg) &INV,
a_ptr = in(reg) a.as_ptr(),
m_ptr = in(reg) MODULUS.0.as_ptr(),
Expand All @@ -693,7 +708,7 @@ impl Fr {
)
}

Self([r0, r1, r2, r3]).sub(MODULUS)
Self([r0, r1, r2, r3])
}

/// Multiplies `rhs` by `self`, returning the result.
Expand Down

0 comments on commit 4ffe4dc

Please sign in to comment.