2005-12-27 Roland McGrath <roland@redhat.com>
[glibc-ports.git] / sysdeps / hppa / hppa1.1 / submul_1.s
blob997bd6d521f7adde31d66fd5470e22c643ef8c38
1 ;! HP-PA-1.1 __mpn_submul_1 -- Multiply a limb vector with a limb and
2 ;! subtract the result from a second limb vector.
4 ;! Copyright (C) 1992, 1993, 1994 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 Lesser General Public License as published by
10 ;! the Free Software Foundation; either version 2.1 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 Lesser General Public
16 ;! License for more details.
18 ;! You should have received a copy of the GNU Lesser 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., 59 Temple Place - Suite 330, Boston,
21 ;! MA 02111-1307, USA.
24 ;! INPUT PARAMETERS
25 ;! res_ptr r26
26 ;! s1_ptr r25
27 ;! size r24
28 ;! s2_limb r23
30 ;! This runs at 12 cycles/limb on a PA7000. With the used instructions, it
31 ;! can not become faster due to data cache contention after a store. On the
32 ;! PA7100 it runs at 11 cycles/limb, and that can not be improved either,
33 ;! since only the xmpyu does not need the integer pipeline, so the only
34 ;! dual-issue we will get are addc+xmpyu. Unrolling could gain a cycle/limb
35 ;! on the PA7100.
37 ;! There are some ideas described in mul_1.s that applies to this code too.
39 ;! It seems possible to make this run as fast as __mpn_addmul_1, if we use
40 ;! sub,>>= %r29,%r20,%r22
41 ;! addi 1,%r28,%r28
42 ;! but that requires reworking the hairy software pipeline...
44 .text
45 .export __mpn_submul_1
46 __mpn_submul_1:
47 .proc
48 .callinfo frame=64,no_calls
49 .entry
51 ldo 64(%r30),%r30
52 fldws,ma 4(%r25),%fr5
53 stw %r23,-16(%r30) ;! move s2_limb ...
54 addib,= -1,%r24,L$just_one_limb
55 fldws -16(%r30),%fr4 ;! ... into fr4
56 add %r0,%r0,%r0 ;! clear carry
57 xmpyu %fr4,%fr5,%fr6
58 fldws,ma 4(%r25),%fr7
59 fstds %fr6,-16(%r30)
60 xmpyu %fr4,%fr7,%fr8
61 ldw -12(%r30),%r20 ;! least significant limb in product
62 ldw -16(%r30),%r28
64 fstds %fr8,-16(%r30)
65 addib,= -1,%r24,L$end
66 ldw -12(%r30),%r1
68 ;! Main loop
69 L$loop:
70 ldws 0(%r26),%r29
71 fldws,ma 4(%r25),%fr5
72 sub %r29,%r20,%r22
73 add %r22,%r20,%r0
74 stws,ma %r22,4(%r26)
75 addc %r28,%r1,%r20
76 xmpyu %fr4,%fr5,%fr6
77 ldw -16(%r30),%r28
78 fstds %fr6,-16(%r30)
79 addc %r0,%r28,%r28
80 addib,<> -1,%r24,L$loop
81 ldw -12(%r30),%r1
83 L$end:
84 ldw 0(%r26),%r29
85 sub %r29,%r20,%r22
86 add %r22,%r20,%r0
87 stws,ma %r22,4(%r26)
88 addc %r28,%r1,%r20
89 ldw -16(%r30),%r28
90 ldws 0(%r26),%r29
91 addc %r0,%r28,%r28
92 sub %r29,%r20,%r22
93 add %r22,%r20,%r0
94 stws,ma %r22,4(%r26)
95 addc %r0,%r28,%r28
96 bv 0(%r2)
97 ldo -64(%r30),%r30
99 L$just_one_limb:
100 xmpyu %fr4,%fr5,%fr6
101 ldw 0(%r26),%r29
102 fstds %fr6,-16(%r30)
103 ldw -12(%r30),%r1
104 ldw -16(%r30),%r28
105 sub %r29,%r1,%r22
106 add %r22,%r1,%r0
107 stw %r22,0(%r26)
108 addc %r0,%r28,%r28
109 bv 0(%r2)
110 ldo -64(%r30),%r30
112 .exit
113 .procend