1 dnl AMD64 mpn_addlsh1_n -- rp[] = up[] + (vp[] << 1)
2 dnl AMD64 mpn_rsblsh1_n -- rp[] = (vp[] << 1) - up[]
4 dnl Copyright 2003, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
6 dnl This file is part of the GNU MP Library.
8 dnl The GNU MP Library is free software; you can redistribute it and/or modify
9 dnl it under the terms of the GNU Lesser General Public License as published
10 dnl by the Free Software Foundation; either version 3 of the License, or (at
11 dnl your option) any later version.
13 dnl The GNU MP Library is distributed in the hope that it will be useful, but
14 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 dnl License for more details.
18 dnl You should have received a copy of the GNU Lesser General Public License
19 dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
21 include(`../config.m4')
33 C Sometimes speed degenerates, supposedly related to that some operand
34 C alignments cause cache conflicts.
36 C The speed is limited by decoding/issue bandwidth. There are 22 instructions
37 C in the loop, which corresponds to ceil(22/3)/4 = 1.83 c/l.
45 ifdef(`OPERATION_addlsh1_n', `
48 define(func, mpn_addlsh1_n)')
49 ifdef(`OPERATION_rsblsh1_n', `
52 define(func, mpn_rsblsh1_n)')
54 MULFUNC_PROLOGUE(mpn_addlsh1_n mpn_rsblsh1_n)
68 xor R32(%rbp), R32(%rbp)
80 sbb R32(%rax), R32(%rax) C save scy
85 ADCSBB 16(up,n,8), %r10
87 sbb R32(%rbp), R32(%rbp) C save acy
94 sbb R32(%rax), R32(%rax) C save scy
99 sbb R32(%rbp), R32(%rbp) C save acy
104 sbb R32(%rax), R32(%rax) C save scy
107 sbb R32(%rbp), R32(%rbp) C save acy
112 L(top): add R32(%rax), R32(%rax) C restore scy
123 sbb R32(%rax), R32(%rax) C save scy
124 add R32(%rbp), R32(%rbp) C restore acy
127 nop C Hammer speedup!
128 ADCSBB 8(up,n,8), %r9
131 ADCSBB 16(up,n,8), %r10
132 ADCSBB 24(up,n,8), %r11
136 sbb R32(%rbp), R32(%rbp) C save acy
141 ifdef(`OPERATION_addlsh1_n',`
142 add R32(%rbp), R32(%rax)
144 ifdef(`OPERATION_rsblsh1_n',`
145 sub R32(%rax), R32(%rbp)
146 movslq R32(%rbp), %rax')