Properly restore AVX registers on x86-64.
[glibc.git] / sysdeps / x86_64 / add_n.S
blob7883f6c8406b9e81260c55a7a59135a406886499
1 /* Add two limb vectors of the same length > 0 and store sum in a third
2    limb vector.
3    Copyright (C) 2004 Free Software Foundation, Inc.
4    This file is part of the GNU MP Library.
6    The GNU MP Library is free software; you can redistribute it and/or modify
7    it under the terms of the GNU Lesser General Public License as published by
8    the Free Software Foundation; either version 2.1 of the License, or (at your
9    option) any later version.
11    The GNU MP Library is distributed in the hope that it will be useful, but
12    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14    License for more details.
16    You should have received a copy of the GNU Lesser General Public License
17    along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
18    the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19    MA 02111-1307, USA. */
21 #include "sysdep.h"
22 #include "asm-syntax.h"
24         .text
25 ENTRY (__mpn_add_n)
26         leaq    (%rsi,%rcx,8), %rsi
27         leaq    (%rdi,%rcx,8), %rdi
28         leaq    (%rdx,%rcx,8), %rdx
29         negq    %rcx
30         xorl    %eax, %eax                      # clear cy
31         .p2align 2
32 L(loop):
33         movq    (%rsi,%rcx,8), %rax
34         movq    (%rdx,%rcx,8), %r10
35         adcq    %r10, %rax
36         movq    %rax, (%rdi,%rcx,8)
37         incq    %rcx
38         jne     L(loop)
39         movq    %rcx, %rax                      # zero %rax
40         adcq    %rax, %rax
41         ret
42 END (__mpn_add_n)