github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/x86/pentium4/sse2/cnd_sub_n.asm (about)

     1  dnl  Intel Pentium-4 mpn_cnd_sub_n -- mpn subtraction.
     2  
     3  dnl  Copyright 2001, 2002, 2013 Free Software Foundation, Inc.
     4  
     5  dnl  This file is part of the GNU MP Library.
     6  dnl
     7  dnl  The GNU MP Library is free software; you can redistribute it and/or modify
     8  dnl  it under the terms of either:
     9  dnl
    10  dnl    * the GNU Lesser General Public License as published by the Free
    11  dnl      Software Foundation; either version 3 of the License, or (at your
    12  dnl      option) any later version.
    13  dnl
    14  dnl  or
    15  dnl
    16  dnl    * the GNU General Public License as published by the Free Software
    17  dnl      Foundation; either version 2 of the License, or (at your option) any
    18  dnl      later version.
    19  dnl
    20  dnl  or both in parallel, as here.
    21  dnl
    22  dnl  The GNU MP Library is distributed in the hope that it will be useful, but
    23  dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    24  dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    25  dnl  for more details.
    26  dnl
    27  dnl  You should have received copies of the GNU General Public License and the
    28  dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
    29  dnl  see https://www.gnu.org/licenses/.
    30  
    31  include(`../config.m4')
    32  
    33  
    34  C			    cycles/limb
    35  C P6 model 0-8,10-12		 -
    36  C P6 model 9   (Banias)		 ?
    37  C P6 model 13  (Dothan)		 4.67
    38  C P4 model 0-1 (Willamette)	 ?
    39  C P4 model 2   (Northwood)	 5
    40  C P4 model 3-4 (Prescott)	 5.25
    41  
    42  defframe(PARAM_SIZE, 20)
    43  defframe(PARAM_SRC2, 16)
    44  defframe(PARAM_SRC1, 12)
    45  defframe(PARAM_DST,  8)
    46  defframe(PARAM_CND,  4)
    47  
    48  dnl  re-use parameter space
    49  define(SAVE_EBX,`PARAM_SRC1')
    50  
    51  define(`cnd', `%mm3')
    52  
    53  	TEXT
    54  	ALIGN(8)
    55  
    56  	ALIGN(8)
    57  PROLOGUE(mpn_cnd_sub_n)
    58  deflit(`FRAME',0)
    59  	pxor	%mm0, %mm0
    60  
    61  	mov	PARAM_CND, %eax
    62  	neg	%eax
    63  	sbb	%eax, %eax
    64  	movd	%eax, cnd
    65  
    66  	mov	PARAM_SRC1, %eax
    67  	mov	%ebx, SAVE_EBX
    68  	mov	PARAM_SRC2, %ebx
    69  	mov	PARAM_DST, %edx
    70  	mov	PARAM_SIZE, %ecx
    71  
    72  	lea	(%eax,%ecx,4), %eax	C src1 end
    73  	lea	(%ebx,%ecx,4), %ebx	C src2 end
    74  	lea	(%edx,%ecx,4), %edx	C dst end
    75  	neg	%ecx			C -size
    76  
    77  L(top):	movd	(%ebx,%ecx,4), %mm2
    78  	movd	(%eax,%ecx,4), %mm1
    79  	pand	cnd, %mm2
    80  	psubq	%mm2, %mm1
    81  
    82  	psubq	%mm0, %mm1
    83  	movd	%mm1, (%edx,%ecx,4)
    84  
    85  	psrlq	$63, %mm1
    86  
    87  	add	$1, %ecx
    88  	jz	L(done_mm1)
    89  
    90  	movd	(%ebx,%ecx,4), %mm2
    91  	movd	(%eax,%ecx,4), %mm0
    92  	pand	cnd, %mm2
    93  	psubq	%mm2, %mm0
    94  
    95  	psubq	%mm1, %mm0
    96  	movd	%mm0, (%edx,%ecx,4)
    97  
    98  	psrlq	$63, %mm0
    99  
   100  	add	$1, %ecx
   101  	jnz	L(top)
   102  
   103  	movd	%mm0, %eax
   104  	mov	SAVE_EBX, %ebx
   105  	emms
   106  	ret
   107  
   108  L(done_mm1):
   109  	movd	%mm1, %eax
   110  	mov	SAVE_EBX, %ebx
   111  	emms
   112  	ret
   113  
   114  EPILOGUE()