Blame mpn/ia64/invert_limb.asm

Packit 5c3484
dnl  IA-64 mpn_invert_limb -- Invert a normalized limb.
Packit 5c3484
Packit 5c3484
dnl  Contributed to the GNU project by Torbjorn Granlund and Kevin Ryde.
Packit 5c3484
Packit 5c3484
dnl  Copyright 2000, 2002, 2004 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
include(`../config.m4')
Packit 5c3484
Packit 5c3484
C INPUT PARAMETERS
Packit 5c3484
C d = r32
Packit 5c3484
Packit 5c3484
C           cycles
Packit 5c3484
C Itanium:    74
Packit 5c3484
C Itanium 2:  50+6
Packit 5c3484
Packit 5c3484
C It should be possible to avoid the xmpy.hu and the following tests by
Packit 5c3484
C explicitly chopping in the last fma.  That would save about 10 cycles.
Packit 5c3484
Packit 5c3484
ASM_START()
Packit 5c3484
	.sdata
Packit 5c3484
	.align 16
Packit 5c3484
ifdef(`HAVE_DOUBLE_IEEE_LITTLE_ENDIAN',`
Packit 5c3484
.LC0:	data4 0x00000000, 0x80000000, 0x0000403f, 0x00000000	C 2^64
Packit 5c3484
.LC1:	data4 0x00000000, 0x80000000, 0x0000407f, 0x00000000	C 2^128
Packit 5c3484
Packit 5c3484
',`ifdef(`HAVE_DOUBLE_IEEE_BIG_ENDIAN',`
Packit 5c3484
.LC0:	data4 0x403f8000, 0x00000000, 0x00000000, 0x00000000	C 2^64
Packit 5c3484
.LC1:	data4 0x407f8000, 0x00000000, 0x00000000, 0x00000000	C 2^128
Packit 5c3484
Packit 5c3484
',`m4_error(`Oops, need to know float endianness
Packit 5c3484
')')')
Packit 5c3484
Packit 5c3484
Packit 5c3484
PROLOGUE(mpn_invert_limb)
Packit 5c3484
		C 00
Packit 5c3484
	addl		r14 = @gprel(.LC0), gp
Packit 5c3484
	addl		r15 = @gprel(.LC1), gp
Packit 5c3484
	setf.sig	f7 = r32
Packit 5c3484
	add		r9 = r32, r32		C check for d = 2^63
Packit 5c3484
	;;	C 01
Packit 5c3484
	ldfe		f10 = [r14]		C 2^64
Packit 5c3484
	ldfe		f8 = [r15]		C 2^128
Packit 5c3484
	cmp.eq		p6, p0 = 0, r9		C check for d = 2^63
Packit 5c3484
	mov		r8 = -1			C retval for 2^63
Packit 5c3484
   (p6)	br.ret.spnt.many b0
Packit 5c3484
	;;	C 07
Packit 5c3484
	fmpy.s1		f11 = f7, f10		C f11 = d * 2^64
Packit 5c3484
	fnma.s1		f6 = f7, f10, f8	C f6 = 2^128 - d * 2^64
Packit 5c3484
	;;	C 11
Packit 5c3484
	frcpa.s1	f8, p6 = f6, f7
Packit 5c3484
	;;	C 15
Packit 5c3484
   (p6)	fnma.s1		f9 = f7, f8, f1
Packit 5c3484
   (p6)	fmpy.s1		f10 = f6, f8
Packit 5c3484
	;;	C 19
Packit 5c3484
   (p6)	fmpy.s1		f11 = f9, f9
Packit 5c3484
   (p6)	fma.s1		f10 = f9, f10, f10
Packit 5c3484
	;;	C 23
Packit 5c3484
   (p6)	fma.s1		f8 = f9, f8, f8
Packit 5c3484
   (p6)	fma.s1		f9 = f11, f10, f10
Packit 5c3484
	;;	C 27
Packit 5c3484
   (p6)	fma.s1		f8 = f11, f8, f8
Packit 5c3484
   (p6)	fnma.s1		f10 = f7, f9, f6
Packit 5c3484
	;;	C 31
Packit 5c3484
   (p6)	fma.s1		f8 = f10, f8, f9
Packit 5c3484
	;;	C 35
Packit 5c3484
	fcvt.fxu.trunc.s1 f8 = f8
Packit 5c3484
	;;	C 39
Packit 5c3484
	getf.sig	r8 = f8
Packit 5c3484
	xmpy.hu		f10 = f8, f7		C di * d
Packit 5c3484
	;;	C 43
Packit 5c3484
	getf.sig	r14 = f10
Packit 5c3484
	andcm		r9 = -1, r32		C one's complement
Packit 5c3484
	;;	C 48
Packit 5c3484
	cmp.ltu		p6, p0 = r9, r14	C got overflow?
Packit 5c3484
	;;	C 49
Packit 5c3484
   (p6)	add		r8 = -1, r8		C adjust di down
Packit 5c3484
	br.ret.sptk.many b0
Packit 5c3484
EPILOGUE()
Packit 5c3484
ASM_END()