diff --git a/constantine.nimble b/constantine.nimble index b5fe831..18ad3f1 100644 --- a/constantine.nimble +++ b/constantine.nimble @@ -302,7 +302,7 @@ const testDesc: seq[tuple[path: string, useGMP: bool]] = @[ ("tests/math_bigints/t_io_bigints.nim", false), # ("tests/math_bigints/t_bigints.nim", false), # ("tests/math_bigints/t_bigints_multimod.nim", false), - # ("tests/math_bigints/t_bigints_mul_vs_gmp.nim", true), + ("tests/math_bigints/t_bigints_mul_vs_gmp.nim", true), # ("tests/math_bigints/t_bigints_mul_high_words_vs_gmp.nim", true), # Big ints - arbitrary precision diff --git a/constantine/math/arithmetic/assembly/limbs_asm_mul_x86.nim b/constantine/math/arithmetic/assembly/limbs_asm_mul_x86.nim index 4ee1631..358f0bd 100644 --- a/constantine/math/arithmetic/assembly/limbs_asm_mul_x86.nim +++ b/constantine/math/arithmetic/assembly/limbs_asm_mul_x86.nim @@ -39,7 +39,7 @@ macro mul_gen[rLen, aLen, bLen: static int](r_PIR: var Limbs[rLen], a_MEM: Limbs let r = asmArray(r_PIR, rLen, PointerInReg, asmInputOutputEarlyClobber, memIndirect = memWrite) # MemOffsettable is the better constraint but compilers say it is impossible. Use early clobber to ensure it is not affected by constant propagation at slight pessimization (reloading it). a = asmArray(a_MEM, aLen, MemOffsettable, asmInput) - b = asmArray(b_MEM, aLen, MemOffsettable, asmInput) + b = asmArray(b_MEM, bLen, MemOffsettable, asmInput) tSym = ident"t" t = asmValue(tSym, Reg, asmOutputEarlyClobber) diff --git a/tests/math_bigints/t_bigints_mul_high_words_vs_gmp.nim b/tests/math_bigints/t_bigints_mul_high_words_vs_gmp.nim index 0cd2363..eecff7a 100644 --- a/tests/math_bigints/t_bigints_mul_high_words_vs_gmp.nim +++ b/tests/math_bigints/t_bigints_mul_high_words_vs_gmp.nim @@ -63,6 +63,10 @@ proc main() = mpz_init(r) mpz_init(a) mpz_init(b) + defer: + mpz_clear(b) + mpz_clear(a) + mpz_clear(r) testRandomModSizes(12, rBits, aBits, bBits, wordsStartIndex): # echo "--------------------------------------------------------------------------------" diff --git a/tests/math_bigints/t_bigints_mul_vs_gmp.nim b/tests/math_bigints/t_bigints_mul_vs_gmp.nim index 083f9c3..eeb17de 100644 --- a/tests/math_bigints/t_bigints_mul_vs_gmp.nim +++ b/tests/math_bigints/t_bigints_mul_vs_gmp.nim @@ -16,6 +16,7 @@ import ../../constantine/math/arithmetic, ../../constantine/platforms/abstractions, # Test utilities + ../../constantine/platforms/codecs, ../../helpers/prng_unsafe echo "\n------------------------------------------------------\n" @@ -60,6 +61,10 @@ proc main() = mpz_init(r) mpz_init(a) mpz_init(b) + defer: + mpz_clear(b) + mpz_clear(a) + mpz_clear(r) testRandomModSizes(12, rBits, aBits, bBits): # echo "--------------------------------------------------------------------------------" @@ -117,8 +122,8 @@ proc main() = discard mpz_export(aBuf[0].addr, aW.addr, GMP_MostSignificantWordFirst, 1, GMP_WordNativeEndian, 0, a) discard mpz_export(bBuf[0].addr, bW.addr, GMP_MostSignificantWordFirst, 1, GMP_WordNativeEndian, 0, b) "\nMultiplication with operands\n" & - " a (" & align($aBits, 4) & "-bit): " & aBuf.toHex & "\n" & - " b (" & align($bBits, 4) & "-bit): " & bBuf.toHex & "\n" & + " a (" & align($aBits, 4) & "-bit): " & aBuf.toHex() & "\n" & + " b (" & align($bBits, 4) & "-bit): " & bBuf.toHex() & "\n" & "into r of size " & align($rBits, 4) & "-bit failed:" & "\n" & " GMP: " & rGMP.toHex() & "\n" & " Constantine: " & rConstantine.toHex() & "\n" &