1 dnl AMD64 mpn_rsh1add_n -- rp[] = (up[] + vp[]) >> 1
3 dnl Copyright 2003, 2005, 2009 Free Software Foundation, Inc.
5 dnl This file is part of the GNU MP Library.
7 dnl The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU Lesser General Public License as published
9 dnl by the Free Software Foundation; either version 3 of the License, or (at
10 dnl your option) any later version.
12 dnl The GNU MP Library is distributed in the hope that it will be useful, but
13 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 dnl License for more details.
17 dnl You should have received a copy of the GNU Lesser General Public License
18 dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
20 include(`../config.m4')
24 C K8,K9: 2.14 (mpn_add_n + mpn_rshift need 4.125)
25 C K10: 2.14 (mpn_add_n + mpn_rshift need 4.125)
30 C * Rewrite to use indexed addressing, like addlsh1.asm and sublsh1.asm.
31 C * Try to approach the cache bandwidth 1.5 c/l. It should be possible.
40 ifdef(`OPERATION_rsh1add_n', `
43 define(func_n, mpn_rsh1add_n)
44 define(func_nc, mpn_rsh1add_nc)')
45 ifdef(`OPERATION_rsh1sub_n', `
48 define(func_n, mpn_rsh1sub_n)
49 define(func_nc, mpn_rsh1sub_nc)')
51 MULFUNC_PROLOGUE(mpn_rsh1add_n mpn_rsh1add_nc mpn_rsh1sub_n mpn_rsh1sub_nc)
61 neg %r8 C set C flag from parameter
75 rcr %rbx C rotate, save acy
76 adc %eax, %eax C return value
82 je L(do) C jump if n = 1 5 9 ...
84 L(n1): cmp $2, R32(%r11)
85 jne L(n2) C jump unless n = 2 6 10 ...
86 add %rbx, %rbx C rotate carry limb, restore acy
97 L(n2): cmp $3, R32(%r11)
98 jne L(n3) C jump unless n = 3 7 11 ...
99 add %rbx, %rbx C rotate carry limb, restore acy
113 L(n3): dec n C come here for n = 4 8 12 ...
114 add %rbx, %rbx C rotate carry limb, restore acy
130 L(cj2): mov %r9, -8(rp)
131 L(cj1): mov %r10, %rbx
137 L(top): add %rbx, %rbx C rotate carry limb, restore acy
151 rcr %r11 C rotate, save acy
167 L(end): mov %rbx, (rp)