xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/powerpc64/mode64/p7/gcd_11.asm (revision 0a3071956a3a9fdebdbf7f338cf2d439b45fc728)
1dnl  PowerPC-64 mpn_gcd_11.
2
3dnl  Copyright 2000-2002, 2005, 2009, 2011-2013 Free Software Foundation, Inc.
4
5dnl  This file is part of the GNU MP Library.
6dnl
7dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8dnl  it under the terms of either:
9dnl
10dnl    * the GNU Lesser General Public License as published by the Free
11dnl      Software Foundation; either version 3 of the License, or (at your
12dnl      option) any later version.
13dnl
14dnl  or
15dnl
16dnl    * the GNU General Public License as published by the Free Software
17dnl      Foundation; either version 2 of the License, or (at your option) any
18dnl      later version.
19dnl
20dnl  or both in parallel, as here.
21dnl
22dnl  The GNU MP Library is distributed in the hope that it will be useful, but
23dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25dnl  for more details.
26dnl
27dnl  You should have received copies of the GNU General Public License and the
28dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
29dnl  see https://www.gnu.org/licenses/.
30
31include(`../config.m4')
32
33C		    cycles/bit (approx)
34C POWER3/PPC630		 -
35C POWER4/PPC970		 -
36C POWER5		 -
37C POWER6		 -
38C POWER7		 7.6    obsolete
39C POWER8		 ?
40C POWER9		 ?
41C Numbers measured with: speed -CD -s16-64 -t48 mpn_gcd_1
42
43C INPUT PARAMETERS
44define(`u0',    `r3')
45define(`v0',    `r4')
46
47define(`cnt',  `r9')dnl
48
49ASM_START()
50PROLOGUE(mpn_gcd_11)
51	li	r12, 63
52	b	L(odd)
53
54	ALIGN(16)
55L(top):	and	r8, r11, r10		C isolate lsb
56	cntlzd	cnt, r8
57	isel	v0, u0, v0, 29		C v = min(u,v)
58	isel	u0, r10, r11, 29	C u = |u - v|
59	subf	cnt, cnt, r12		C cnt = 63-cnt
60	srd	u0, u0, cnt
61L(odd):	cmpld	cr7, v0, u0
62	subf	r10, u0, v0		C r10 = v - u
63	subf	r11, v0, u0		C r11 = u - v
64	bne	cr7, L(top)
65
66L(end):	blr
67EPILOGUE()
68