1dnl  PowerPC-64 mpn_sublsh1_n -- rp[] = up[] - (vp[] << 1)
2
3dnl  Copyright 2003, 2005 Free Software Foundation, Inc.
4
5dnl  This file is part of the GNU MP Library.
6
7dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8dnl  it under the terms of the GNU Lesser General Public License as published
9dnl  by the Free Software Foundation; either version 3 of the License, or (at
10dnl  your option) any later version.
11
12dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15dnl  License for more details.
16
17dnl  You should have received a copy of the GNU Lesser General Public License
18dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20include(`../config.m4')
21
22C		cycles/limb
23C POWER3/PPC630:     2		(1.5 c/l should be possible)
24C POWER4/PPC970:     4		(2.0 c/l should be possible)
25
26C INPUT PARAMETERS
27C rp	r3
28C up	r4
29C vp	r5
30C n	r6
31
32define(`rp',`r3')
33define(`up',`r4')
34define(`vp',`r5')
35
36define(`s0',`r6')
37define(`s1',`r7')
38define(`u0',`r8')
39define(`v0',`r10')
40define(`v1',`r11')
41
42ASM_START()
43PROLOGUE(mpn_sublsh1_n)
44	mtctr	r6		C put n in ctr
45
46	ld	v0, 0(vp)	C load v limb
47	ld	u0, 0(up)	C load u limb
48	addic	up, up, -8	C update up; set cy
49	addi	rp, rp, -8	C update rp
50	sldi	s1, v0, 1
51	bdz	L(end)		C If done, skip loop
52
53L(oop):	ld	v1, 8(vp)	C load v limb
54	subfe	s1, s1, u0	C add limbs with cy, set cy
55	std	s1, 8(rp)	C store result limb
56	srdi	s0, v0, 63	C shift down previous v limb
57	ldu	u0, 16(up)	C load u limb and update up
58	rldimi	s0, v1, 1, 0	C left shift v limb and merge with prev v limb
59
60	bdz	L(exit)		C decrement ctr and exit if done
61
62	ldu	v0, 16(vp)	C load v limb and update vp
63	subfe	s0, s0, u0	C add limbs with cy, set cy
64	stdu	s0, 16(rp)	C store result limb and update rp
65	srdi	s1, v1, 63	C shift down previous v limb
66	ld	u0, 8(up)	C load u limb
67	rldimi	s1, v0, 1, 0	C left shift v limb and merge with prev v limb
68
69	bdnz	L(oop)		C decrement ctr and loop back
70
71L(end):	subfe	r7, s1, u0
72	std	r7, 8(rp)	C store last result limb
73	srdi	r3, v0, 63
74	subfze	r3, r3
75	neg	r3, r3
76	blr
77L(exit):	subfe	r7, s0, u0
78	std	r7, 16(rp)	C store last result limb
79	srdi	r3, v1, 63
80	subfze	r3, r3
81	neg	r3, r3
82	blr
83EPILOGUE()
84