Blame mpn/power/submul_1.asm

Packit 5c3484
dnl  IBM POWER mpn_submul_1 -- Multiply a limb vector with a limb and subtract
Packit 5c3484
dnl  the result from a second limb vector.
Packit 5c3484
Packit 5c3484
dnl  Copyright 1992, 1994, 1999-2001 Free Software Foundation, Inc.
Packit 5c3484
Packit 5c3484
dnl  This file is part of the GNU MP Library.
Packit 5c3484
dnl
Packit 5c3484
dnl  The GNU MP Library is free software; you can redistribute it and/or modify
Packit 5c3484
dnl  it under the terms of either:
Packit 5c3484
dnl
Packit 5c3484
dnl    * the GNU Lesser General Public License as published by the Free
Packit 5c3484
dnl      Software Foundation; either version 3 of the License, or (at your
Packit 5c3484
dnl      option) any later version.
Packit 5c3484
dnl
Packit 5c3484
dnl  or
Packit 5c3484
dnl
Packit 5c3484
dnl    * the GNU General Public License as published by the Free Software
Packit 5c3484
dnl      Foundation; either version 2 of the License, or (at your option) any
Packit 5c3484
dnl      later version.
Packit 5c3484
dnl
Packit 5c3484
dnl  or both in parallel, as here.
Packit 5c3484
dnl
Packit 5c3484
dnl  The GNU MP Library is distributed in the hope that it will be useful, but
Packit 5c3484
dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 5c3484
dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
Packit 5c3484
dnl  for more details.
Packit 5c3484
dnl
Packit 5c3484
dnl  You should have received copies of the GNU General Public License and the
Packit 5c3484
dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
Packit 5c3484
dnl  see https://www.gnu.org/licenses/.
Packit 5c3484
Packit 5c3484
Packit 5c3484
dnl  INPUT PARAMETERS
Packit 5c3484
dnl  res_ptr	r3
Packit 5c3484
dnl  s1_ptr	r4
Packit 5c3484
dnl  size	r5
Packit 5c3484
dnl  s2_limb	r6
Packit 5c3484
Packit 5c3484
dnl  The POWER architecture has no unsigned 32x32->64 bit multiplication
Packit 5c3484
dnl  instruction.  To obtain that operation, we have to use the 32x32->64
Packit 5c3484
dnl  signed multiplication instruction, and add the appropriate compensation to
Packit 5c3484
dnl  the high limb of the result.  We add the multiplicand if the multiplier
Packit 5c3484
dnl  has its most significant bit set, and we add the multiplier if the
Packit 5c3484
dnl  multiplicand has its most significant bit set.  We need to preserve the
Packit 5c3484
dnl  carry flag between each iteration, so we have to compute the compensation
Packit 5c3484
dnl  carefully (the natural, srai+and doesn't work).  Since all POWER can
Packit 5c3484
dnl  branch in zero cycles, we use conditional branches for the compensation.
Packit 5c3484
Packit 5c3484
include(`../config.m4')
Packit 5c3484
Packit 5c3484
ASM_START()
Packit 5c3484
PROLOGUE(mpn_submul_1)
Packit 5c3484
	cal	3,-4(3)
Packit 5c3484
	l	0,0(4)
Packit 5c3484
	cmpi	0,6,0
Packit 5c3484
	mtctr	5
Packit 5c3484
	mul	9,0,6
Packit 5c3484
	srai	7,0,31
Packit 5c3484
	and	7,7,6
Packit 5c3484
	mfmq	11
Packit 5c3484
	cax	9,9,7
Packit 5c3484
	l	7,4(3)
Packit 5c3484
	sf	8,11,7		C add res_limb
Packit 5c3484
	a	11,8,11		C invert cy (r11 is junk)
Packit 5c3484
	blt	Lneg
Packit 5c3484
Lpos:	bdz	Lend
Packit 5c3484
Packit 5c3484
Lploop:	lu	0,4(4)
Packit 5c3484
	stu	8,4(3)
Packit 5c3484
	cmpi	0,0,0
Packit 5c3484
	mul	10,0,6
Packit 5c3484
	mfmq	0
Packit 5c3484
	ae	11,0,9		C low limb + old_cy_limb + old cy
Packit 5c3484
	l	7,4(3)
Packit 5c3484
	aze	10,10		C propagate cy to new cy_limb
Packit 5c3484
	sf	8,11,7		C add res_limb
Packit 5c3484
	a	11,8,11		C invert cy (r11 is junk)
Packit 5c3484
	bge	Lp0
Packit 5c3484
	cax	10,10,6		C adjust high limb for negative limb from s1
Packit 5c3484
Lp0:	bdz	Lend0
Packit 5c3484
	lu	0,4(4)
Packit 5c3484
	stu	8,4(3)
Packit 5c3484
	cmpi	0,0,0
Packit 5c3484
	mul	9,0,6
Packit 5c3484
	mfmq	0
Packit 5c3484
	ae	11,0,10
Packit 5c3484
	l	7,4(3)
Packit 5c3484
	aze	9,9
Packit 5c3484
	sf	8,11,7
Packit 5c3484
	a	11,8,11		C invert cy (r11 is junk)
Packit 5c3484
	bge	Lp1
Packit 5c3484
	cax	9,9,6		C adjust high limb for negative limb from s1
Packit 5c3484
Lp1:	bdn	Lploop
Packit 5c3484
Packit 5c3484
	b	Lend
Packit 5c3484
Packit 5c3484
Lneg:	cax	9,9,0
Packit 5c3484
	bdz	Lend
Packit 5c3484
Lnloop:	lu	0,4(4)
Packit 5c3484
	stu	8,4(3)
Packit 5c3484
	cmpi	0,0,0
Packit 5c3484
	mul	10,0,6
Packit 5c3484
	mfmq	7
Packit 5c3484
	ae	11,7,9
Packit 5c3484
	l	7,4(3)
Packit 5c3484
	ae	10,10,0		C propagate cy to new cy_limb
Packit 5c3484
	sf	8,11,7		C add res_limb
Packit 5c3484
	a	11,8,11		C invert cy (r11 is junk)
Packit 5c3484
	bge	Ln0
Packit 5c3484
	cax	10,10,6		C adjust high limb for negative limb from s1
Packit 5c3484
Ln0:	bdz	Lend0
Packit 5c3484
	lu	0,4(4)
Packit 5c3484
	stu	8,4(3)
Packit 5c3484
	cmpi	0,0,0
Packit 5c3484
	mul	9,0,6
Packit 5c3484
	mfmq	7
Packit 5c3484
	ae	11,7,10
Packit 5c3484
	l	7,4(3)
Packit 5c3484
	ae	9,9,0		C propagate cy to new cy_limb
Packit 5c3484
	sf	8,11,7		C add res_limb
Packit 5c3484
	a	11,8,11		C invert cy (r11 is junk)
Packit 5c3484
	bge	Ln1
Packit 5c3484
	cax	9,9,6		C adjust high limb for negative limb from s1
Packit 5c3484
Ln1:	bdn	Lnloop
Packit 5c3484
	b	Lend
Packit 5c3484
Packit 5c3484
Lend0:	cal	9,0(10)
Packit 5c3484
Lend:	st	8,4(3)
Packit 5c3484
	aze	3,9
Packit 5c3484
	br
Packit 5c3484
EPILOGUE(mpn_submul_1)