* stdlib/Makefile (mpn-stuff): New target.
[glibc.git] / sysdeps / alpha / alphaev5 / add_n.s
blob66cf82b3c3586ec3357080822815996d47726288
1 # Alpha __mpn_add_n -- Add two limb vectors of the same length > 0 and
2 # store sum in a third limb vector.
4 # Copyright (C) 1995 Free Software Foundation, Inc.
6 # This file is part of the GNU MP Library.
8 # The GNU MP Library is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU Library General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or (at your
11 # option) any later version.
13 # The GNU MP Library is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
16 # License for more details.
18 # You should have received a copy of the GNU Library General Public License
19 # along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20 # the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 # INPUT PARAMETERS
24 # res_ptr $16
25 # s1_ptr $17
26 # s2_ptr $18
27 # size $19
29 .set noreorder
30 .set noat
31 .text
32 .align 3
33 .globl __mpn_add_n
34 .ent __mpn_add_n
35 __mpn_add_n:
36 .frame $30,0,$26,0
38 or $31,$31,$25 # clear cy
39 subq $19,4,$19 # decr loop cnt
40 blt $19,.Lend2 # if less than 4 limbs, goto 2nd loop
41 # Start software pipeline for 1st loop
42 ldq $0,0($18)
43 ldq $1,8($18)
44 ldq $4,0($17)
45 ldq $5,8($17)
46 addq $17,32,$17 # update s1_ptr
47 ldq $2,16($18)
48 addq $0,$4,$20 # 1st main add
49 ldq $3,24($18)
50 subq $19,4,$19 # decr loop cnt
51 ldq $6,-16($17)
52 cmpult $20,$0,$25 # compute cy from last add
53 ldq $7,-8($17)
54 addq $1,$25,$28 # cy add
55 addq $18,32,$18 # update s2_ptr
56 addq $5,$28,$21 # 2nd main add
57 cmpult $28,$25,$8 # compute cy from last add
58 blt $19,.Lend1 # if less than 4 limbs remain, jump
59 # 1st loop handles groups of 4 limbs in a software pipeline
60 .align 4
61 .Loop: cmpult $21,$28,$25 # compute cy from last add
62 ldq $0,0($18)
63 or $8,$25,$25 # combine cy from the two adds
64 ldq $1,8($18)
65 addq $2,$25,$28 # cy add
66 ldq $4,0($17)
67 addq $28,$6,$22 # 3rd main add
68 ldq $5,8($17)
69 cmpult $28,$25,$8 # compute cy from last add
70 cmpult $22,$28,$25 # compute cy from last add
71 stq $20,0($16)
72 or $8,$25,$25 # combine cy from the two adds
73 stq $21,8($16)
74 addq $3,$25,$28 # cy add
75 addq $28,$7,$23 # 4th main add
76 cmpult $28,$25,$8 # compute cy from last add
77 cmpult $23,$28,$25 # compute cy from last add
78 addq $17,32,$17 # update s1_ptr
79 or $8,$25,$25 # combine cy from the two adds
80 addq $16,32,$16 # update res_ptr
81 addq $0,$25,$28 # cy add
82 ldq $2,16($18)
83 addq $4,$28,$20 # 1st main add
84 ldq $3,24($18)
85 cmpult $28,$25,$8 # compute cy from last add
86 ldq $6,-16($17)
87 cmpult $20,$28,$25 # compute cy from last add
88 ldq $7,-8($17)
89 or $8,$25,$25 # combine cy from the two adds
90 subq $19,4,$19 # decr loop cnt
91 stq $22,-16($16)
92 addq $1,$25,$28 # cy add
93 stq $23,-8($16)
94 addq $5,$28,$21 # 2nd main add
95 addq $18,32,$18 # update s2_ptr
96 cmpult $28,$25,$8 # compute cy from last add
97 bge $19,.Loop
98 # Finish software pipeline for 1st loop
99 .Lend1: cmpult $21,$28,$25 # compute cy from last add
100 or $8,$25,$25 # combine cy from the two adds
101 addq $2,$25,$28 # cy add
102 addq $28,$6,$22 # 3rd main add
103 cmpult $28,$25,$8 # compute cy from last add
104 cmpult $22,$28,$25 # compute cy from last add
105 stq $20,0($16)
106 or $8,$25,$25 # combine cy from the two adds
107 stq $21,8($16)
108 addq $3,$25,$28 # cy add
109 addq $28,$7,$23 # 4th main add
110 cmpult $28,$25,$8 # compute cy from last add
111 cmpult $23,$28,$25 # compute cy from last add
112 or $8,$25,$25 # combine cy from the two adds
113 addq $16,32,$16 # update res_ptr
114 stq $22,-16($16)
115 stq $23,-8($16)
116 .Lend2: addq $19,4,$19 # restore loop cnt
117 beq $19,.Lret
118 # Start software pipeline for 2nd loop
119 ldq $0,0($18)
120 ldq $4,0($17)
121 subq $19,1,$19
122 beq $19,.Lend0
123 # 2nd loop handles remaining 1-3 limbs
124 .align 4
125 .Loop0: addq $0,$25,$28 # cy add
126 ldq $0,8($18)
127 addq $4,$28,$20 # main add
128 ldq $4,8($17)
129 addq $18,8,$18
130 cmpult $28,$25,$8 # compute cy from last add
131 addq $17,8,$17
132 stq $20,0($16)
133 cmpult $20,$28,$25 # compute cy from last add
134 subq $19,1,$19 # decr loop cnt
135 or $8,$25,$25 # combine cy from the two adds
136 addq $16,8,$16
137 bne $19,.Loop0
138 .Lend0: addq $0,$25,$28 # cy add
139 addq $4,$28,$20 # main add
140 cmpult $28,$25,$8 # compute cy from last add
141 cmpult $20,$28,$25 # compute cy from last add
142 stq $20,0($16)
143 or $8,$25,$25 # combine cy from the two adds
145 .Lret: or $25,$31,$0 # return cy
146 ret $31,($26),1
147 .end __mpn_add_n