github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/sparc64/ultrasparc1234/sqr_diagonal.asm (about)

     1  dnl  SPARC v9 64-bit mpn_sqr_diagonal.
     2  
     3  dnl  Copyright 2001, 2002 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  C		   cycles/limb
    34  C UltraSPARC 1&2:     22
    35  C UltraSPARC 3:	      36
    36  
    37  C This was generated by the Sun C compiler.  It runs at 22 cycles/limb on the
    38  C UltraSPARC-1/2, three cycles slower than theoretically possible for optimal
    39  C code using the same algorithm.  For 1-3 limbs, a special loop was generated,
    40  C which causes performance problems in particular for 2 and 3 limbs.
    41  C Ultimately, this should be replaced by hand-written code in the same software
    42  C pipeline style as e.g., addmul_1.asm.
    43  
    44  ASM_START()
    45  	REGISTER(%g2,#scratch)
    46  	REGISTER(%g3,#scratch)
    47  PROLOGUE(mpn_sqr_diagonal)
    48  	save	%sp, -240, %sp
    49  
    50  	sethi	%hi(0x1ffc00), %o0
    51  	sethi	%hi(0x3ffc00), %o1
    52  	add	%o0, 1023, %o7
    53  	cmp	%i2, 4
    54  	add	%o1, 1023, %o4
    55  	or	%g0, %i1, %g1
    56  	or	%g0, %i0, %o0
    57  	bl,pn	%xcc, .Lsmall
    58  	or	%g0, 0, %g2
    59  
    60  	ldx	[%i1], %o1
    61  	add	%i1, 24, %g1
    62  	or	%g0, 3, %g2
    63  	srlx	%o1, 42, %g3
    64  	stx	%g3, [%sp+2279]
    65  	and	%o1, %o7, %o2
    66  	stx	%o2, [%sp+2263]
    67  	srlx	%o1, 21, %o1
    68  	ldd	[%sp+2279], %f0
    69  	and	%o1, %o7, %o1
    70  	stx	%o1, [%sp+2271]
    71  	ldx	[%i1+8], %o2
    72  	fxtod	%f0, %f12
    73  	srlx	%o2, 21, %o1
    74  	and	%o2, %o7, %g3
    75  	ldd	[%sp+2263], %f2
    76  	fmuld	%f12, %f12, %f10
    77  	srlx	%o2, 42, %o2
    78  	ldd	[%sp+2271], %f0
    79  	and	%o1, %o7, %o1
    80  	fxtod	%f2, %f8
    81  	stx	%o2, [%sp+2279]
    82  	stx	%o1, [%sp+2271]
    83  	fxtod	%f0, %f0
    84  	stx	%g3, [%sp+2263]
    85  	fdtox	%f10, %f14
    86  	fmuld	%f12, %f8, %f6
    87  	ldx	[%i1+16], %o2
    88  	std	%f14, [%sp+2255]
    89  	fmuld	%f0, %f0, %f2
    90  	fmuld	%f8, %f8, %f10
    91  	srlx	%o2, 42, %o1
    92  	faddd	%f6, %f6, %f6
    93  	fmuld	%f12, %f0, %f12
    94  	fmuld	%f0, %f8, %f8
    95  	ldd	[%sp+2279], %f0
    96  	ldd	[%sp+2263], %f4
    97  	fdtox	%f10, %f10
    98  	std	%f10, [%sp+2239]
    99  	faddd	%f2, %f6, %f6
   100  	ldd	[%sp+2271], %f2
   101  	fdtox	%f12, %f12
   102  	std	%f12, [%sp+2247]
   103  	fdtox	%f8, %f8
   104  	std	%f8, [%sp+2231]
   105  	fdtox	%f6, %f6
   106  	std	%f6, [%sp+2223]
   107  
   108  .Loop:	srlx	%o2, 21, %g3
   109  	stx	%o1, [%sp+2279]
   110  	add	%g2, 1, %g2
   111  	and	%g3, %o7, %o1
   112  	ldx	[%sp+2255], %g4
   113  	cmp	%g2, %i2
   114  	stx	%o1, [%sp+2271]
   115  	add	%g1, 8, %g1
   116  	add	%o0, 16, %o0
   117  	ldx	[%sp+2239], %o1
   118  	fxtod	%f0, %f10
   119  	fxtod	%f4, %f14
   120  	ldx	[%sp+2231], %i0
   121  	ldx	[%sp+2223], %g5
   122  	ldx	[%sp+2247], %g3
   123  	and	%o2, %o7, %o2
   124  	fxtod	%f2, %f8
   125  	fmuld	%f10, %f10, %f0
   126  	stx	%o2, [%sp+2263]
   127  	fmuld	%f10, %f14, %f6
   128  	ldx	[%g1-8], %o2
   129  	fmuld	%f10, %f8, %f12
   130  	fdtox	%f0, %f2
   131  	ldd	[%sp+2279], %f0
   132  	fmuld	%f8, %f8, %f4
   133  	faddd	%f6, %f6, %f6
   134  	fmuld	%f14, %f14, %f10
   135  	std	%f2, [%sp+2255]
   136  	sllx	%g4, 20, %g4
   137  	ldd	[%sp+2271], %f2
   138  	fmuld	%f8, %f14, %f8
   139  	sllx	%i0, 22, %i1
   140  	fdtox	%f12, %f12
   141  	std	%f12, [%sp+2247]
   142  	sllx	%g5, 42, %i0
   143  	add	%o1, %i1, %o1
   144  	faddd	%f4, %f6, %f6
   145  	ldd	[%sp+2263], %f4
   146  	add	%o1, %i0, %o1
   147  	add	%g3, %g4, %g3
   148  	fdtox	%f10, %f10
   149  	std	%f10, [%sp+2239]
   150  	srlx	%o1, 42, %g4
   151  	and	%g5, %o4, %i0
   152  	fdtox	%f8, %f8
   153  	std	%f8, [%sp+2231]
   154  	srlx	%g5, 22, %g5
   155  	sub	%g4, %i0, %g4
   156  	fdtox	%f6, %f6
   157  	std	%f6, [%sp+2223]
   158  	srlx	%g4, 63, %g4
   159  	add	%g3, %g5, %g3
   160  	add	%g3, %g4, %g3
   161  	stx	%o1, [%o0-16]
   162  	srlx	%o2, 42, %o1
   163  	bl,pt	%xcc, .Loop
   164  	stx	%g3, [%o0-8]
   165  
   166  	stx	%o1, [%sp+2279]
   167  	srlx	%o2, 21, %o1
   168  	fxtod	%f0, %f16
   169  	ldx	[%sp+2223], %g3
   170  	fxtod	%f4, %f6
   171  	and	%o2, %o7, %o3
   172  	stx	%o3, [%sp+2263]
   173  	fxtod	%f2, %f4
   174  	and	%o1, %o7, %o1
   175  	ldx	[%sp+2231], %o2
   176  	sllx	%g3, 42, %g4
   177  	fmuld	%f16, %f16, %f14
   178  	stx	%o1, [%sp+2271]
   179  	fmuld	%f16, %f6, %f8
   180  	add	%o0, 48, %o0
   181  	ldx	[%sp+2239], %o1
   182  	sllx	%o2, 22, %o2
   183  	fmuld	%f4, %f4, %f10
   184  	ldx	[%sp+2255], %o3
   185  	fdtox	%f14, %f14
   186  	fmuld	%f4, %f6, %f2
   187  	std	%f14, [%sp+2255]
   188  	faddd	%f8, %f8, %f12
   189  	add	%o1, %o2, %o2
   190  	fmuld	%f16, %f4, %f4
   191  	ldd	[%sp+2279], %f0
   192  	sllx	%o3, 20, %g5
   193  	add	%o2, %g4, %o2
   194  	fmuld	%f6, %f6, %f6
   195  	srlx	%o2, 42, %o3
   196  	and	%g3, %o4, %g4
   197  	srlx	%g3, 22, %g3
   198  	faddd	%f10, %f12, %f16
   199  	ldd	[%sp+2271], %f12
   200  	ldd	[%sp+2263], %f8
   201  	fxtod	%f0, %f0
   202  	sub	%o3, %g4, %o3
   203  	ldx	[%sp+2247], %o1
   204  	srlx	%o3, 63, %o3
   205  	fdtox	%f2, %f10
   206  	fxtod	%f8, %f8
   207  	std	%f10, [%sp+2231]
   208  	fdtox	%f6, %f6
   209  	std	%f6, [%sp+2239]
   210  	add	%o1, %g5, %o1
   211  	fmuld	%f0, %f0, %f2
   212  	fdtox	%f16, %f16
   213  	std	%f16, [%sp+2223]
   214  	add	%o1, %g3, %o1
   215  	fdtox	%f4, %f4
   216  	std	%f4, [%sp+2247]
   217  	fmuld	%f0, %f8, %f10
   218  	fxtod	%f12, %f12
   219  	add	%o1, %o3, %o1
   220  	stx	%o2, [%o0-48]
   221  	fmuld	%f8, %f8, %f6
   222  	stx	%o1, [%o0-40]
   223  	fdtox	%f2, %f2
   224  	ldx	[%sp+2231], %o2
   225  	faddd	%f10, %f10, %f10
   226  	ldx	[%sp+2223], %g3
   227  	fmuld	%f12, %f12, %f4
   228  	fdtox	%f6, %f6
   229  	ldx	[%sp+2239], %o1
   230  	sllx	%o2, 22, %o2
   231  	fmuld	%f12, %f8, %f8
   232  	sllx	%g3, 42, %g5
   233  	ldx	[%sp+2255], %o3
   234  	fmuld	%f0, %f12, %f0
   235  	add	%o1, %o2, %o2
   236  	faddd	%f4, %f10, %f4
   237  	ldx	[%sp+2247], %o1
   238  	add	%o2, %g5, %o2
   239  	and	%g3, %o4, %g4
   240  	fdtox	%f8, %f8
   241  	sllx	%o3, 20, %g5
   242  	std	%f8, [%sp+2231]
   243  	fdtox	%f0, %f0
   244  	srlx	%o2, 42, %o3
   245  	add	%o1, %g5, %o1
   246  	fdtox	%f4, %f4
   247  	srlx	%g3, 22, %g3
   248  	sub	%o3, %g4, %o3
   249  	std	%f6, [%sp+2239]
   250  	std	%f4, [%sp+2223]
   251  	srlx	%o3, 63, %o3
   252  	add	%o1, %g3, %o1
   253  	std	%f2, [%sp+2255]
   254  	add	%o1, %o3, %o1
   255  	std	%f0, [%sp+2247]
   256  	stx	%o2, [%o0-32]
   257  	stx	%o1, [%o0-24]
   258  	ldx	[%sp+2231], %o2
   259  	ldx	[%sp+2223], %o3
   260  	ldx	[%sp+2239], %o1
   261  	sllx	%o2, 22, %o2
   262  	sllx	%o3, 42, %g5
   263  	ldx	[%sp+2255], %g4
   264  	and	%o3, %o4, %g3
   265  	add	%o1, %o2, %o2
   266  	ldx	[%sp+2247], %o1
   267  	add	%o2, %g5, %o2
   268  	stx	%o2, [%o0-16]
   269  	sllx	%g4, 20, %g4
   270  	srlx	%o2, 42, %o2
   271  	add	%o1, %g4, %o1
   272  	srlx	%o3, 22, %o3
   273  	sub	%o2, %g3, %o2
   274  	srlx	%o2, 63, %o2
   275  	add	%o1, %o3, %o1
   276  	add	%o1, %o2, %o1
   277  	stx	%o1, [%o0-8]
   278  	ret
   279  	restore	%g0, %g0, %g0
   280  .Lsmall:
   281  	ldx	[%g1], %o2
   282  .Loop0:
   283  	and	%o2, %o7, %o1
   284  	stx	%o1, [%sp+2263]
   285  	add	%g2, 1, %g2
   286  	srlx	%o2, 21, %o1
   287  	add	%g1, 8, %g1
   288  	srlx	%o2, 42, %o2
   289  	stx	%o2, [%sp+2279]
   290  	and	%o1, %o7, %o1
   291  	ldd	[%sp+2263], %f0
   292  	cmp	%g2, %i2
   293  	stx	%o1, [%sp+2271]
   294  	fxtod	%f0, %f6
   295  	ldd	[%sp+2279], %f0
   296  	ldd	[%sp+2271], %f4
   297  	fxtod	%f0, %f2
   298  	fmuld	%f6, %f6, %f0
   299  	fxtod	%f4, %f10
   300  	fmuld	%f2, %f6, %f4
   301  	fdtox	%f0, %f0
   302  	std	%f0, [%sp+2239]
   303  	fmuld	%f10, %f6, %f8
   304  	fmuld	%f10, %f10, %f0
   305  	faddd	%f4, %f4, %f6
   306  	fmuld	%f2, %f2, %f4
   307  	fdtox	%f8, %f8
   308  	std	%f8, [%sp+2231]
   309  	fmuld	%f2, %f10, %f2
   310  	faddd	%f0, %f6, %f0
   311  	fdtox	%f4, %f4
   312  	std	%f4, [%sp+2255]
   313  	fdtox	%f2, %f2
   314  	std	%f2, [%sp+2247]
   315  	fdtox	%f0, %f0
   316  	std	%f0, [%sp+2223]
   317  	ldx	[%sp+2239], %o1
   318  	ldx	[%sp+2255], %g4
   319  	ldx	[%sp+2231], %o2
   320  	sllx	%g4, 20, %g4
   321  	ldx	[%sp+2223], %o3
   322  	sllx	%o2, 22, %o2
   323  	sllx	%o3, 42, %g5
   324  	add	%o1, %o2, %o2
   325  	ldx	[%sp+2247], %o1
   326  	add	%o2, %g5, %o2
   327  	stx	%o2, [%o0]
   328  	and	%o3, %o4, %g3
   329  	srlx	%o2, 42, %o2
   330  	add	%o1, %g4, %o1
   331  	srlx	%o3, 22, %o3
   332  	sub	%o2, %g3, %o2
   333  	srlx	%o2, 63, %o2
   334  	add	%o1, %o3, %o1
   335  	add	%o1, %o2, %o1
   336  	stx	%o1, [%o0+8]
   337  	add	%o0, 16, %o0
   338  	bl,a,pt	%xcc, .Loop0
   339  	ldx	[%g1], %o2
   340  	ret
   341  	restore	%g0, %g0, %g0
   342  EPILOGUE(mpn_sqr_diagonal)