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

mercurial at gmplib.org mercurial at gmplib.org
Sat Jul 15 12:44:46 CEST 2023


details:   /var/hg/gmp/rev/54d1162e1301
changeset: 18387:54d1162e1301
user:      Torbjorn Granlund <tg at gmplib.org>
date:      Sat Jul 15 12:42:25 2023 +0200
description:
Improve Risc V asm support.

details:   /var/hg/gmp/rev/6c33d9d4f0f4
changeset: 18388:6c33d9d4f0f4
user:      Torbjorn Granlund <tg at gmplib.org>
date:      Sat Jul 15 12:44:39 2023 +0200
description:
ChangeLog

diffstat:

 ChangeLog                   |    5 +
 mpn/riscv/64/cnd_aors_n.asm |   97 +++++++++++++++++++++++++++++++++++
 mpn/riscv/64/copyd.asm      |   87 +++++++++++++++++++++++++++++++
 mpn/riscv/64/copyi.asm      |   84 ++++++++++++++++++++++++++++++
 mpn/riscv/64/lshift.asm     |  121 ++++++++++++++++++++++++++++++++++++++++++++
 mpn/riscv/64/rshift.asm     |  119 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 513 insertions(+), 0 deletions(-)

diffs (truncated from 540 to 300 lines):

diff -r 7e88bbf045ab -r 6c33d9d4f0f4 ChangeLog
--- a/ChangeLog	Sat Jul 15 12:18:07 2023 +0200
+++ b/ChangeLog	Sat Jul 15 12:44:39 2023 +0200
@@ -1,3 +1,8 @@
+2023-07-15  Torbjörn Granlund  <tg at gmplib.org>
+
+	* mpn/riscv/64: Improve Risc V asm support.
+	* mpn/loongarch/64: Provide basic Loongarch asm support.
+
 2023-07-06  Marc Glisse  <marc.glisse at inria.fr>
 
 	* doc/gmp.texi: Mention snapshots in bug report instructions.
diff -r 7e88bbf045ab -r 6c33d9d4f0f4 mpn/riscv/64/cnd_aors_n.asm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpn/riscv/64/cnd_aors_n.asm	Sat Jul 15 12:44:39 2023 +0200
@@ -0,0 +1,97 @@
+dnl  RISC-V/64 mpn_cnd_add_n and mpn_cnd_sub_n.
+
+dnl  Copyright 2016, 2023 Free Software Foundation, Inc.
+
+dnl  This file is part of the GNU MP Library.
+dnl
+dnl  The GNU MP Library is free software; you can redistribute it and/or modify
+dnl  it under the terms of either:
+dnl
+dnl    * the GNU Lesser General Public License as published by the Free
+dnl      Software Foundation; either version 3 of the License, or (at your
+dnl      option) any later version.
+dnl
+dnl  or
+dnl
+dnl    * the GNU General Public License as published by the Free Software
+dnl      Foundation; either version 2 of the License, or (at your option) any
+dnl      later version.
+dnl
+dnl  or both in parallel, as here.
+dnl
+dnl  The GNU MP Library is distributed in the hope that it will be useful, but
+dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+dnl  for more details.
+dnl
+dnl  You should have received copies of the GNU General Public License and the
+dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
+dnl  see https://www.gnu.org/licenses/.
+
+include(`../config.m4')
+
+C  INPUT PARAMETERS
+define(`cnd',	`a0')
+define(`rp',	`a1')
+define(`up',	`a2')
+define(`vp',	`a3')
+define(`n',	`a4')
+
+define(`mask',	`t5')
+
+ifdef(`OPERATION_cnd_add_n',`
+    define(`ADDSUB',	`add')
+    define(`CMPCY',	`sltu	$1, $2, $3')
+    define(`func',	`mpn_cnd_add_n')
+')
+ifdef(`OPERATION_cnd_sub_n',`
+    define(`ADDSUB',	`sub')
+    define(`CMPCY',	`sltu	$1, $3, $4')
+    define(`func',	`mpn_cnd_sub_n')
+')
+
+MULFUNC_PROLOGUE(mpn_cnd_add_n mpn_cnd_sub_n)
+
+ASM_START()
+PROLOGUE(func)
+	li	t6, 0
+
+	sltiu	mask, cnd, 1
+	addi	mask, mask, -1
+
+	andi	t0, n, 1
+	beq	t0, x0, L(top)
+	addi	up, up, 8
+	addi	vp, vp, -8
+	addi	rp, rp, -8
+	addi	n, n, -1
+	j	L(mid)
+
+L(top):	ld	a0, 0(up)
+	ld	a6, 0(vp)
+	addi	n, n, -2	C bookkeeping
+	addi	up, up, 16	C bookkeeping
+	and	a6, a6, mask
+	ADDSUB	t0, a0, a6
+	CMPCY(	t2, t0, a0, a6)
+	ADDSUB	t4, t0, t6	C cycle 3, 9, ...
+	CMPCY(	t3, t4, t0, t6)	C cycle 4, 10, ...
+	sd	t4, 0(rp)
+	add	t6, t2, t3	C cycle 5, 11, ...
+L(mid):	ld	a5, -8(up)
+	ld	a7, 8(vp)
+	addi	vp, vp, 16	C bookkeeping
+	addi	rp, rp, 16	C bookkeeping
+	and	a7, a7, mask
+	ADDSUB	t1, a5, a7
+	CMPCY(	t2, t1, a5, a7)
+	ADDSUB	t4, t1, t6	C cycle 0, 6, ...
+	CMPCY(	t3, t4, t1, t6)	C cycle 1, 7, ...
+	sd	t4, -8(rp)
+	add	t6, t2, t3	C cycle 2, 8, ...
+	bne	n, x0, L(top)	C bookkeeping
+
+L(end):	mv	a0, t6
+	ret
+EPILOGUE()
+ASM_END()
diff -r 7e88bbf045ab -r 6c33d9d4f0f4 mpn/riscv/64/copyd.asm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpn/riscv/64/copyd.asm	Sat Jul 15 12:44:39 2023 +0200
@@ -0,0 +1,87 @@
+dnl  RISC-V/64 mpn_copyd
+
+dnl  Copyright 2023 Free Software Foundation, Inc.
+
+dnl  This file is part of the GNU MP Library.
+dnl
+dnl  The GNU MP Library is free software; you can redistribute it and/or modify
+dnl  it under the terms of either:
+dnl
+dnl    * the GNU Lesser General Public License as published by the Free
+dnl      Software Foundation; either version 3 of the License, or (at your
+dnl      option) any later version.
+dnl
+dnl  or
+dnl
+dnl    * the GNU General Public License as published by the Free Software
+dnl      Foundation; either version 2 of the License, or (at your option) any
+dnl      later version.
+dnl
+dnl  or both in parallel, as here.
+dnl
+dnl  The GNU MP Library is distributed in the hope that it will be useful, but
+dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+dnl  for more details.
+dnl
+dnl  You should have received copies of the GNU General Public License and the
+dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
+dnl  see https://www.gnu.org/licenses/.
+
+include(`../config.m4')
+
+C  INPUT PARAMETERS
+define(`rp',	`a0')
+define(`ap',	`a1')
+define(`n',	`a2')
+
+define(`i',	`a6')
+
+ASM_START()
+PROLOGUE(mpn_copyd)
+	slli	t0, n, 3
+	add	ap, ap, t0
+	add	rp, rp, t0
+	srli	i, n, 2
+
+	andi	t0, n, 1
+	andi	t1, n, 2
+	bnez	t0, L(bx1)
+L(bx0):	beqz	n, L(ret)
+	ld	t0, -8(ap)
+	bnez	t1, L(b10)
+L(b00):	addi	rp, rp, 8
+	addi	i, i, -1
+	j	L(b0)
+L(b10):	addi	ap, ap, 16
+	addi	rp, rp, 24
+	j	L(b2)
+L(bx1):	ld	t2, -8(ap)
+	bnez	t1, L(b11)
+	beqz	i, L(1)
+	addi	ap, ap, -8
+	addi	i, i, -1
+	j	L(b1)
+L(1):	sd	t2, -8(rp)
+	ret
+L(b11):	addi	ap, ap, 8
+	addi	rp, rp, 16
+	j	L(b3)
+
+	ALIGN(	16)
+L(top):	addi	ap, ap, -32
+	addi	rp, rp, -32
+	addi	i, i, -1
+L(b1):	ld	t0, -8(ap)
+	sd	t2, -8(rp)
+L(b0):	ld	t2, -16(ap)
+	sd	t0, -16(rp)
+L(b3):	ld	t0, -24(ap)
+	sd	t2, -24(rp)
+L(b2):	ld	t2, -32(ap)
+	sd	t0, -32(rp)
+	bnez	i, L(top)
+
+L(end):	sd	t2, -40(rp)
+L(ret):	ret
+EPILOGUE()
diff -r 7e88bbf045ab -r 6c33d9d4f0f4 mpn/riscv/64/copyi.asm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpn/riscv/64/copyi.asm	Sat Jul 15 12:44:39 2023 +0200
@@ -0,0 +1,84 @@
+dnl  RISC-V/64 mpn_copyi
+
+dnl  Copyright 2023 Free Software Foundation, Inc.
+
+dnl  This file is part of the GNU MP Library.
+dnl
+dnl  The GNU MP Library is free software; you can redistribute it and/or modify
+dnl  it under the terms of either:
+dnl
+dnl    * the GNU Lesser General Public License as published by the Free
+dnl      Software Foundation; either version 3 of the License, or (at your
+dnl      option) any later version.
+dnl
+dnl  or
+dnl
+dnl    * the GNU General Public License as published by the Free Software
+dnl      Foundation; either version 2 of the License, or (at your option) any
+dnl      later version.
+dnl
+dnl  or both in parallel, as here.
+dnl
+dnl  The GNU MP Library is distributed in the hope that it will be useful, but
+dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+dnl  for more details.
+dnl
+dnl  You should have received copies of the GNU General Public License and the
+dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
+dnl  see https://www.gnu.org/licenses/.
+
+include(`../config.m4')
+
+C  INPUT PARAMETERS
+define(`rp',	`a0')
+define(`ap',	`a1')
+define(`n',	`a2')
+
+define(`i',	`a6')
+
+ASM_START()
+PROLOGUE(mpn_copyi)
+	srli	i, n, 2
+
+	andi	t0, n, 1
+	andi	t1, n, 2
+	bnez	t0, L(bx1)
+L(bx0):	beqz	n, L(ret)
+	ld	t0, 0(ap)
+	bnez	t1, L(b10)
+L(b00):	addi	rp, rp, -8
+	addi	i, i, -1
+	j	L(b0)
+L(b10):	addi	ap, ap, -16
+	addi	rp, rp, -24
+	j	L(b2)
+L(bx1):	ld	t2, 0(ap)
+	bnez	t1, L(b11)
+	beqz	i, L(1)
+	addi	ap, ap, 8
+	addi	i, i, -1
+	j	L(b1)
+L(1):	sd	t2, 0(rp)
+	ret
+L(b11):	addi	ap, ap, -8
+	addi	rp, rp, -16
+	j	L(b3)
+
+	ALIGN(	16)
+L(top):	addi	ap, ap, 32
+	addi	rp, rp, 32
+	addi	i, i, -1
+L(b1):	ld	t0, 0(ap)
+	sd	t2, 0(rp)
+L(b0):	ld	t2, 8(ap)
+	sd	t0, 8(rp)
+L(b3):	ld	t0, 16(ap)
+	sd	t2, 16(rp)
+L(b2):	ld	t2, 24(ap)
+	sd	t0, 24(rp)
+	bnez	i, L(top)
+
+L(end):	sd	t2, 32(rp)
+L(ret):	ret
+EPILOGUE()
diff -r 7e88bbf045ab -r 6c33d9d4f0f4 mpn/riscv/64/lshift.asm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpn/riscv/64/lshift.asm	Sat Jul 15 12:44:39 2023 +0200
@@ -0,0 +1,121 @@
+dnl  RISC-V/64 mpn_lshift
+
+dnl  Contributed to the GNU project by Torbjorn Granlund.
+


More information about the gmp-commit mailing list