Blame sysdeps/alpha/mul_1.S

Packit Service 82fcde
 # Alpha 21064 __mpn_mul_1 -- Multiply a limb vector with a limb and store
Packit Service 82fcde
 # the result in a second limb vector.
Packit Service 82fcde
Packit Service 82fcde
 # Copyright (C) 1992-2018 Free Software Foundation, Inc.
Packit Service 82fcde
Packit Service 82fcde
 # This file is part of the GNU MP Library.
Packit Service 82fcde
Packit Service 82fcde
 # The GNU MP Library is free software; you can redistribute it and/or modify
Packit Service 82fcde
 # it under the terms of the GNU Lesser General Public License as published by
Packit Service 82fcde
 # the Free Software Foundation; either version 2.1 of the License, or (at your
Packit Service 82fcde
 # option) any later version.
Packit Service 82fcde
Packit Service 82fcde
 # The GNU MP Library is distributed in the hope that it will be useful, but
Packit Service 82fcde
 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit Service 82fcde
 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
Packit Service 82fcde
 # License for more details.
Packit Service 82fcde
Packit Service 82fcde
 # You should have received a copy of the GNU Lesser General Public License
Packit Service 82fcde
 # along with the GNU MP Library.  If not, see <http://www.gnu.org/licenses/>.
Packit Service 82fcde
Packit Service 82fcde
Packit Service 82fcde
 # INPUT PARAMETERS
Packit Service 82fcde
 # res_ptr	r16
Packit Service 82fcde
 # s1_ptr	r17
Packit Service 82fcde
 # size		r18
Packit Service 82fcde
 # s2_limb	r19
Packit Service 82fcde
Packit Service 82fcde
 # This code runs at 42 cycles/limb on the EV4 and 18 cycles/limb on the EV5.
Packit Service 82fcde
Packit Service 82fcde
 # To improve performance for long multiplications, we would use
Packit Service 82fcde
 # 'fetch' for S1 and 'fetch_m' for RES.  It's not obvious how to use
Packit Service 82fcde
 # these instructions without slowing down the general code: 1. We can
Packit Service 82fcde
 # only have two prefetches in operation at any time in the Alpha
Packit Service 82fcde
 # architecture.  2. There will seldom be any special alignment
Packit Service 82fcde
 # between RES_PTR and S1_PTR.  Maybe we can simply divide the current
Packit Service 82fcde
 # loop into an inner and outer loop, having the inner loop handle
Packit Service 82fcde
 # exactly one prefetch block?
Packit Service 82fcde
Packit Service 82fcde
	.set	noreorder
Packit Service 82fcde
	.set	noat
Packit Service 82fcde
.text
Packit Service 82fcde
	.align	3
Packit Service 82fcde
	.globl	__mpn_mul_1
Packit Service 82fcde
	.ent	__mpn_mul_1 2
Packit Service 82fcde
__mpn_mul_1:
Packit Service 82fcde
	.frame	$30,0,$26
Packit Service 82fcde
Packit Service 82fcde
	ldq	$2,0($17)	# $2 = s1_limb
Packit Service 82fcde
	subq	$18,1,$18	# size--
Packit Service 82fcde
	mulq	$2,$19,$3	# $3 = prod_low
Packit Service 82fcde
	bic	$31,$31,$4	# clear cy_limb
Packit Service 82fcde
	umulh	$2,$19,$0	# $0 = prod_high
Packit Service 82fcde
	beq	$18,Lend1	# jump if size was == 1
Packit Service 82fcde
	ldq	$2,8($17)	# $2 = s1_limb
Packit Service 82fcde
	subq	$18,1,$18	# size--
Packit Service 82fcde
	stq	$3,0($16)
Packit Service 82fcde
	beq	$18,Lend2	# jump if size was == 2
Packit Service 82fcde
Packit Service 82fcde
	.align	3
Packit Service 82fcde
Loop:	mulq	$2,$19,$3	# $3 = prod_low
Packit Service 82fcde
	addq	$4,$0,$0	# cy_limb = cy_limb + 'cy'
Packit Service 82fcde
	subq	$18,1,$18	# size--
Packit Service 82fcde
	umulh	$2,$19,$4	# $4 = cy_limb
Packit Service 82fcde
	ldq	$2,16($17)	# $2 = s1_limb
Packit Service 82fcde
	addq	$17,8,$17	# s1_ptr++
Packit Service 82fcde
	addq	$3,$0,$3	# $3 = cy_limb + prod_low
Packit Service 82fcde
	stq	$3,8($16)
Packit Service 82fcde
	cmpult	$3,$0,$0	# $0 = carry from (cy_limb + prod_low)
Packit Service 82fcde
	addq	$16,8,$16	# res_ptr++
Packit Service 82fcde
	bne	$18,Loop
Packit Service 82fcde
Packit Service 82fcde
Lend2:	mulq	$2,$19,$3	# $3 = prod_low
Packit Service 82fcde
	addq	$4,$0,$0	# cy_limb = cy_limb + 'cy'
Packit Service 82fcde
	umulh	$2,$19,$4	# $4 = cy_limb
Packit Service 82fcde
	addq	$3,$0,$3	# $3 = cy_limb + prod_low
Packit Service 82fcde
	cmpult	$3,$0,$0	# $0 = carry from (cy_limb + prod_low)
Packit Service 82fcde
	stq	$3,8($16)
Packit Service 82fcde
	addq	$4,$0,$0	# cy_limb = prod_high + cy
Packit Service 82fcde
	ret	$31,($26),1
Packit Service 82fcde
Lend1:	stq	$3,0($16)
Packit Service 82fcde
	ret	$31,($26),1
Packit Service 82fcde
Packit Service 82fcde
	.end	__mpn_mul_1