[Gmp-commit] /var/hg/gmp: 3 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Wed Oct 6 23:24:02 UTC 2021


details:   /var/hg/gmp/rev/51fdae00a4d7
changeset: 18252:51fdae00a4d7
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Tue Oct 05 12:18:34 2021 +0200
description:
rand/randmts.c: Update a comment about seeds.

details:   /var/hg/gmp/rev/8e8ae372361b
changeset: 18253:8e8ae372361b
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Oct 07 01:22:25 2021 +0200
description:
mpn/x86_64/addaddmul_1msb0.asm: Support DOS ABI, reorder branches.

details:   /var/hg/gmp/rev/6a2372c2f54f
changeset: 18254:6a2372c2f54f
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Oct 07 01:23:31 2021 +0200
description:
ChangeLog

diffstat:

 ChangeLog                      |    2 +
 mpn/x86_64/addaddmul_1msb0.asm |  103 +++++++++++++++++-----------------------
 rand/randmts.c                 |    7 ++
 3 files changed, 52 insertions(+), 60 deletions(-)

diffs (197 lines):

diff -r 17aaa74eab0b -r 6a2372c2f54f ChangeLog
--- a/ChangeLog	Sat Oct 02 01:29:00 2021 +0200
+++ b/ChangeLog	Thu Oct 07 01:23:31 2021 +0200
@@ -5,6 +5,8 @@
 	* gmp-impl.h: #include output of gen-sieve.
 	* Makefile.am: Add rules for gen-sieve and sieve_table.h.
 
+	* mpn/x86_64/addaddmul_1msb0.asm: Support DOS ABI, reorder branches.
+
 2021-09-26  Torbjörn Granlund  <tg at gmplib.org>
 
 	* configure.ac (s390): Make sure to always include main asm directory.
diff -r 17aaa74eab0b -r 6a2372c2f54f mpn/x86_64/addaddmul_1msb0.asm
--- a/mpn/x86_64/addaddmul_1msb0.asm	Sat Oct 02 01:29:00 2021 +0200
+++ b/mpn/x86_64/addaddmul_1msb0.asm	Thu Oct 07 01:23:31 2021 +0200
@@ -1,6 +1,6 @@
 dnl  AMD64 mpn_addaddmul_1msb0, R = Au + Bv, u,v < 2^63.
 
-dnl  Copyright 2008 Free Software Foundation, Inc.
+dnl  Copyright 2008, 2021 Free Software Foundation, Inc.
 
 dnl  This file is part of the GNU MP Library.
 dnl
@@ -53,11 +53,16 @@
 
 define(`bp', `%rbp')
 
+ABI_SUPPORT(DOS64)
+ABI_SUPPORT(STD64)
+
 ASM_START()
 	TEXT
 	ALIGN(16)
 PROLOGUE(mpn_addaddmul_1msb0)
-	push	%r12
+        FUNC_ENTRY(4)
+IFDOS(`	mov	56(%rsp), %r8	')
+IFDOS(`	mov	64(%rsp), %r9	')
 	push	%rbp
 
 	lea	(ap,n,8), ap
@@ -67,56 +72,61 @@
 
 	mov	(ap,n,8), %rax
 	mul	%r8
-	mov	%rax, %r12
+	mov	%rax, %r11
 	mov	(bp,n,8), %rax
 	mov	%rdx, %r10
 	add	$3, n
 	jns	L(end)
 
+	push	%r13
+
 	ALIGN(16)
 L(top):	mul	%r9
-	add	%rax, %r12
+	add	%rax, %r11
 	mov	-16(ap,n,8), %rax
 	adc	%rdx, %r10
-	mov	%r12, -24(rp,n,8)
+	mov	%r11, -24(rp,n,8)
 	mul	%r8
 	add	%rax, %r10
 	mov	-16(bp,n,8), %rax
-	mov	$0, R32(%r11)
-	adc	%rdx, %r11
+	mov	$0, R32(%r13)
+	adc	%rdx, %r13
 	mul	%r9
 	add	%rax, %r10
 	mov	-8(ap,n,8), %rax
+	adc	%rdx, %r13
+	mov	%r10, -16(rp,n,8)
+	mul	%r8
+	add	%rax, %r13
+	mov	-8(bp,n,8), %rax
+	mov	$0, R32(%r11)
 	adc	%rdx, %r11
-	mov	%r10, -16(rp,n,8)
+	mul	%r9
+	add	%rax, %r13
+	adc	%rdx, %r11
+	mov	(ap,n,8), %rax
 	mul	%r8
 	add	%rax, %r11
-	mov	-8(bp,n,8), %rax
-	mov	$0, R32(%r12)
-	adc	%rdx, %r12
-	mul	%r9
-	add	%rax, %r11
-	adc	%rdx, %r12
-	mov	(ap,n,8), %rax
-	mul	%r8
-	add	%rax, %r12
-	mov	%r11, -8(rp,n,8)
+	mov	%r13, -8(rp,n,8)
 	mov	(bp,n,8), %rax
 	mov	$0, R32(%r10)
 	adc	%rdx, %r10
 	add	$3, n
 	js	L(top)
 
-L(end):	cmp	$1, R32(n)
-	ja	2f
-	jz	1f
+	pop	%r13
 
-	mul	%r9
-	add	%rax, %r12
-	mov	-16(ap), %rax
+L(end):	mul	%r9
+	add	%rax, %r11
 	adc	%rdx, %r10
-	mov	%r12, -24(rp)
-	mul	%r8
+	cmp	$1, R32(n)
+	ja	L(two)
+	mov	-16(ap,n,8), %rax
+	mov	%r11, -24(rp,n,8)
+	mov	%r10, %r11
+	jz	L(one)
+
+L(nul):	mul	%r8
 	add	%rax, %r10
 	mov	-16(bp), %rax
 	mov	$0, R32(%r11)
@@ -126,45 +136,18 @@
 	mov	-8(ap), %rax
 	adc	%rdx, %r11
 	mov	%r10, -16(rp)
-	mul	%r8
+L(one):	mul	%r8
 	add	%rax, %r11
 	mov	-8(bp), %rax
-	mov	$0, R32(%r12)
-	adc	%rdx, %r12
+	mov	$0, R32(%r10)
+	adc	%rdx, %r10
 	mul	%r9
 	add	%rax, %r11
-	adc	%rdx, %r12
-	mov	%r11, -8(rp)
-	mov	%r12, %rax
-	pop	%rbp
-	pop	%r12
-	ret
+	adc	%rdx, %r10
 
-1:	mul	%r9
-	add	%rax, %r12
-	mov	-8(ap), %rax
-	adc	%rdx, %r10
-	mov	%r12, -16(rp)
-	mul	%r8
-	add	%rax, %r10
-	mov	-8(bp), %rax
-	mov	$0, R32(%r11)
-	adc	%rdx, %r11
-	mul	%r9
-	add	%rax, %r10
-	adc	%rdx, %r11
-	mov	%r10, -8(rp)
-	mov	%r11, %rax
-	pop	%rbp
-	pop	%r12
-	ret
-
-2:	mul	%r9
-	add	%rax, %r12
-	mov	%r12, -8(rp)
-	adc	%rdx, %r10
+L(two):	mov	%r11, -8(rp)
 	mov	%r10, %rax
-	pop	%rbp
-	pop	%r12
+L(ret):	pop	%rbp
+	FUNC_EXIT()
 	ret
 EPILOGUE()
diff -r 17aaa74eab0b -r 6a2372c2f54f rand/randmts.c
--- a/rand/randmts.c	Sat Oct 02 01:29:00 2021 +0200
+++ b/rand/randmts.c	Thu Oct 07 01:23:31 2021 +0200
@@ -102,6 +102,13 @@
    with seeds 2^19937-20027, 2^19937-20026, ... the exact same sequences
    are obtained as with seeds 0, 1, etc.; it also means that seed -1
    produces the same sequence as seed 2^19937-20028, etc.
+
+   Moreover, c) is not guaranted, there are many seeds yielding to the
+   same sequence, because gcd (1074888996, 2^19937 - 20023 - 1) = 12.
+   E.g. x and x'=x*19^((2^19937-20023-1) / 12) mod (2^19937-20023), if
+   chosen as seed1, generate the same seed2, for every x.
+   Similarly x" can be obtained from x', obtaining 12 different
+   values.
  */
 
 static void


More information about the gmp-commit mailing list