.
[glibc-ports.git] / sysdeps / alpha / mul_1.s
blob165c281ac6f7db51ef039543a418fe449311ed0b
1 # Alpha 21064 __mpn_mul_1 -- Multiply a limb vector with a limb and store
2 # the result in a second limb vector.
4 # Copyright (C) 1992, 1994, 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 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 r16
26 # s1_ptr r17
27 # size r18
28 # s2_limb r19
30 # This code runs at 42 cycles/limb on the EV4 and 18 cycles/limb on the EV5.
32 # To improve performance for long multiplications, we would use
33 # 'fetch' for S1 and 'fetch_m' for RES. It's not obvious how to use
34 # these instructions without slowing down the general code: 1. We can
35 # only have two prefetches in operation at any time in the Alpha
36 # architecture. 2. There will seldom be any special alignment
37 # between RES_PTR and S1_PTR. Maybe we can simply divide the current
38 # loop into an inner and outer loop, having the inner loop handle
39 # exactly one prefetch block?
41 .set noreorder
42 .set noat
43 .text
44 .align 3
45 .globl __mpn_mul_1
46 .ent __mpn_mul_1 2
47 __mpn_mul_1:
48 .frame $30,0,$26
50 ldq $2,0($17) # $2 = s1_limb
51 subq $18,1,$18 # size--
52 mulq $2,$19,$3 # $3 = prod_low
53 bic $31,$31,$4 # clear cy_limb
54 umulh $2,$19,$0 # $0 = prod_high
55 beq $18,Lend1 # jump if size was == 1
56 ldq $2,8($17) # $2 = s1_limb
57 subq $18,1,$18 # size--
58 stq $3,0($16)
59 beq $18,Lend2 # jump if size was == 2
61 .align 3
62 Loop: mulq $2,$19,$3 # $3 = prod_low
63 addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
64 subq $18,1,$18 # size--
65 umulh $2,$19,$4 # $4 = cy_limb
66 ldq $2,16($17) # $2 = s1_limb
67 addq $17,8,$17 # s1_ptr++
68 addq $3,$0,$3 # $3 = cy_limb + prod_low
69 stq $3,8($16)
70 cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
71 addq $16,8,$16 # res_ptr++
72 bne $18,Loop
74 Lend2: mulq $2,$19,$3 # $3 = prod_low
75 addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
76 umulh $2,$19,$4 # $4 = cy_limb
77 addq $3,$0,$3 # $3 = cy_limb + prod_low
78 cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
79 stq $3,8($16)
80 addq $4,$0,$0 # cy_limb = prod_high + cy
81 ret $31,($26),1
82 Lend1: stq $3,0($16)
83 ret $31,($26),1
85 .end __mpn_mul_1