Skip to content

Commit cba2139

Browse files
committed
feat(crandall reduction): prevent asm for mul on 32-bit reloaded
1 parent b48a69e commit cba2139

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

constantine/math/arithmetic/assembly/limbs_asm_crandall_x86.nim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import
1010
# Standard library
1111
std/macros,
1212
# Internal
13-
constantine/platforms/abstractions,
14-
./limbs_asm_mul_x86
13+
constantine/platforms/abstractions
14+
15+
when UseASM_X86_64:
16+
import ./limbs_asm_mul_x86
1517

1618
# ############################################################
1719
#

constantine/math/arithmetic/assembly/limbs_asm_crandall_x86_adx_bmi2.nim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import
1111
std/macros,
1212
# Internal
1313
constantine/platforms/abstractions,
14-
./limbs_asm_mul_x86_adx_bmi2,
1514
./limbs_asm_crandall_x86
1615

16+
when UseASM_X86_64:
17+
import ./limbs_asm_mul_x86_adx_bmi2
18+
1719
# ############################################################
1820
#
1921
# Assembly implementation of finite fields
@@ -178,6 +180,7 @@ func mulCranPartialReduce_asm_adx*[N: static int](
178180
r: var Limbs[N],
179181
a, b: Limbs[N],
180182
m: static int, c: static SecretWord) =
183+
static: doAssert UseASM_X86_64, "x86-32 does not have enough registers for squaring"
181184
var r2 {.noInit.}: Limbs[2*N]
182185
r2.mul_asm_adx(a, b)
183186
r.reduceCrandallPartial_asm_adx(r2, m, c)
@@ -186,6 +189,7 @@ func squareCranPartialReduce_asm_adx*[N: static int](
186189
r: var Limbs[N],
187190
a: Limbs[N],
188191
m: static int, c: static SecretWord) =
192+
static: doAssert UseASM_X86_64, "x86-32 does not have enough registers for squaring"
189193
var r2 {.noInit.}: Limbs[2*N]
190194
r2.square_asm_adx(a)
191195
r.reduceCrandallPartial_asm_adx(r2, m, c)

0 commit comments

Comments
 (0)