xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/arm/v5/gcd_11.asm (revision 72c7faa4dbb41dbb0238d6b4a109da0d4b236dd4)
1dnl  ARM v5 mpn_gcd_11.
2
3dnl  Based on the K7 gcd_1.asm, by Kevin Ryde.  Rehacked for ARM by Torbjörn
4dnl  Granlund.
5
6dnl  Copyright 2000-2002, 2005, 2009, 2011, 2012 Free Software Foundation, Inc.
7
8dnl  This file is part of the GNU MP Library.
9dnl
10dnl  The GNU MP Library is free software; you can redistribute it and/or modify
11dnl  it under the terms of either:
12dnl
13dnl    * the GNU Lesser General Public License as published by the Free
14dnl      Software Foundation; either version 3 of the License, or (at your
15dnl      option) any later version.
16dnl
17dnl  or
18dnl
19dnl    * the GNU General Public License as published by the Free Software
20dnl      Foundation; either version 2 of the License, or (at your option) any
21dnl      later version.
22dnl
23dnl  or both in parallel, as here.
24dnl
25dnl  The GNU MP Library is distributed in the hope that it will be useful, but
26dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
27dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28dnl  for more details.
29dnl
30dnl  You should have received copies of the GNU General Public License and the
31dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
32dnl  see https://www.gnu.org/licenses/.
33
34include(`../config.m4')
35
36C	     cycles/bit (approx)
37C StrongARM	 -
38C XScale	 ?
39C Cortex-A5	 6.45	obsolete
40C Cortex-A7	 6.41	obsolete
41C Cortex-A8	 5.0	obsolete
42C Cortex-A9	 5.9	obsolete
43C Cortex-A15	 4.40	obsolete
44C Cortex-A17	 5.68	obsolete
45C Cortex-A53	 4.37	obsolete
46C Numbers measured with: speed -CD -s8-32 -t24 mpn_gcd_1
47
48define(`u0',    `r0')
49define(`v0',    `r1')
50
51ASM_START()
52	TEXT
53	ALIGN(16)
54PROLOGUE(mpn_gcd_11)
55	subs	r3, u0, v0	C			0
56	beq	L(end)		C
57
58	ALIGN(16)
59L(top):	sub	r2, v0, u0	C			0,5
60	and	r12, r2, r3	C			1
61	clz	r12, r12	C			2
62	rsb	r12, r12, #31	C			3
63	rsbcc	r3, r3, #0	C v = abs(u-v), even	1
64	movcs	u0, v0		C u = min(u,v)		1
65	lsr	v0, r3, r12	C			4
66	subs	r3, u0, v0	C			5
67	bne	L(top)		C
68
69L(end):	bx	lr
70EPILOGUE()
71