Skip to content

Commit

Permalink
feat(crandall reduction): prevent asm for mul on 32-bit reloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Jul 27, 2024
1 parent 0f8f289 commit 57911e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import
# Standard library
std/macros,
# Internal
constantine/platforms/abstractions,
./limbs_asm_mul_x86
constantine/platforms/abstractions

when UseASM_X86_64:
import ./limbs_asm_mul_x86

# ############################################################
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import
std/macros,
# Internal
constantine/platforms/abstractions,
./limbs_asm_mul_x86_adx_bmi2,
./limbs_asm_crandall_x86

when UseASM_X86_64:
import ./limbs_asm_mul_x86_adx_bmi2

# ############################################################
#
# Assembly implementation of finite fields
Expand Down Expand Up @@ -178,6 +180,7 @@ func mulCranPartialReduce_asm_adx*[N: static int](
r: var Limbs[N],
a, b: Limbs[N],
m: static int, c: static SecretWord) =
static: doAssert UseASM_X86_64, "x86-32 does not have enough registers for squaring"
var r2 {.noInit.}: Limbs[2*N]
r2.mul_asm_adx(a, b)
r.reduceCrandallPartial_asm_adx(r2, m, c)
Expand All @@ -186,6 +189,7 @@ func squareCranPartialReduce_asm_adx*[N: static int](
r: var Limbs[N],
a: Limbs[N],
m: static int, c: static SecretWord) =
static: doAssert UseASM_X86_64, "x86-32 does not have enough registers for squaring"
var r2 {.noInit.}: Limbs[2*N]
r2.square_asm_adx(a)
r.reduceCrandallPartial_asm_adx(r2, m, c)
Expand Down

0 comments on commit 57911e8

Please sign in to comment.