1 dnl SPARC v9 32-bit mpn_sqr_diagonal.
3 dnl Copyright 2001, 2003 Free Software Foundation, Inc.
5 dnl This file is part of the GNU MP Library.
7 dnl The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU Lesser General Public License as published
9 dnl by the Free Software Foundation; either version 3 of the License, or (at
10 dnl your option) any later version.
12 dnl The GNU MP Library is distributed in the hope that it will be useful, but
13 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 dnl License for more details.
17 dnl You should have received a copy of the GNU Lesser General Public License
18 dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
21 include(`../config.m4')
28 C This code uses a very deep software pipeline, due to the need for moving data
29 C forth and back between the integer registers and floating-point registers.
31 C A VIS variant of this code would make the pipeline less deep, since the
32 C masking now done in the integer unit could take place in the floating-point
33 C unit using the FAND instruction. It would be possible to save several cycles
36 C On UltraSPARC 1 and 2, this code runs at 11 cycles/limb from the Dcache and
37 C not much slower from the Ecache. It would perhaps be possible to shave off
38 C one cycle, but not easily. We cannot do better than 10 cycles/limb with the
39 C used instructions, since we have 10 memory operations per limb. But a VIS
40 C variant could run three cycles faster than the corresponding non-VIS code.
42 C This is non-pipelined code showing the algorithm:
45 C lduw [up+0],%g4 C 00000000hhhhllll
46 C sllx %g4,16,%g3 C 0000hhhhllll0000
47 C or %g3,%g4,%g2 C 0000hhhhXXXXllll
48 C andn %g2,%g5,%g2 C 0000hhhh0000llll
51 C fitod %f0,%f4 C hi16
52 C fitod %f1,%f6 C lo16
73 define(`fanop',`fitod %f12,%f10') dnl A quasi nop running in the FA pipe
82 PROLOGUE(mpn_sqr_diagonal)
87 ld [%o7+.Lnoll-.Lpc],%f8',
88 ` sethi %hi(.Lnoll),%g1
89 ld [%g1+%lo(.Lnoll)],%f8')
91 sethi %hi(0xffff0000),%g5
95 add %i1,4,%i1 C s1_ptr++
96 sllx %g4,16,%g3 C 0000hhhhllll0000
97 or %g3,%g4,%g2 C 0000hhhhXXXXllll
100 andn %g2,%g5,%g2 C 0000hhhh0000llll
102 add %i1,4,%i1 C s1_ptr++
125 add %i1,4,%i1 C s1_ptr++
126 sllx %g4,16,%g3 C 0000hhhhllll0000
127 or %g3,%g4,%g2 C 0000hhhhXXXXllll
130 andn %g2,%g5,%g2 C 0000hhhh0000llll
134 add %i1,4,%i1 C s1_ptr++
164 add %i1,4,%i1 C s1_ptr++
166 sllx %g4,16,%g3 C 0000hhhhllll0000
167 or %g3,%g4,%g2 C 0000hhhhXXXXllll
171 andn %g2,%g5,%g2 C 0000hhhh0000llll
179 add %i1,4,%i1 C s1_ptr++
207 add %i1,4,%i1 C s1_ptr++
210 sllx %g4,16,%g3 C 0000hhhhllll0000
212 or %g3,%g4,%g2 C 0000hhhhXXXXllll
218 andn %g2,%g5,%g2 C 0000hhhh0000llll
228 add %i1,4,%i1 C s1_ptr++
243 add %i1,4,%i1 C s1_ptr++
246 sllx %g4,16,%g3 C 0000hhhhllll0000
248 or %g3,%g4,%g2 C 0000hhhhXXXXllll
254 andn %g2,%g5,%g2 C 0000hhhh0000llll
272 ldx [%fp-24],%g2 C p16
277 ldx [%fp-16],%g1 C p0
280 sllx %g2,16,%g2 C align p16
281 add %i0,8,%i0 C res_ptr++
285 add %g2,%g1,%g1 C add p16 to p0 (ADD1)
286 add %i1,4,%i1 C s1_ptr++
295 sllx %g4,16,%g3 C 0000hhhhllll0000
300 or %g3,%g4,%g2 C 0000hhhhXXXXllll
306 andn %g2,%g5,%g2 C 0000hhhh0000llll
322 ldx [%fp-40],%g2 C p16
327 ldx [%fp-32],%g1 C p0
330 sllx %g2,16,%g2 C align p16
331 add %i0,8,%i0 C res_ptr++
335 add %g2,%g1,%g1 C add p16 to p0 (ADD1)
336 add %i1,4,%i1 C s1_ptr++
345 sllx %g4,16,%g3 C 0000hhhhllll0000
350 or %g3,%g4,%g2 C 0000hhhhXXXXllll
356 andn %g2,%g5,%g2 C 0000hhhh0000llll
361 .L5: add %fp, 80, %l3
367 .Lend: add %fp, 72, %l3
371 .Ltail: stx %g2,[%l3]
377 sllx %g2,16,%g2 C align p16
378 add %i0,8,%i0 C res_ptr++
381 add %g2,%g1,%g1 C add p16 to p0 (ADD1)
382 add %i1,4,%i1 C s1_ptr++
398 sllx %g2,16,%g2 C align p16
399 add %i0,8,%i0 C res_ptr++
402 add %g2,%g1,%g1 C add p16 to p0 (ADD1)
418 sllx %g2,16,%g2 C align p16
419 add %i0,8,%i0 C res_ptr++
421 add %g2,%g1,%g1 C add p16 to p0 (ADD1)
432 sllx %g2,16,%g2 C align p16
433 add %i0,8,%i0 C res_ptr++
434 add %g2,%g1,%g1 C add p16 to p0 (ADD1)
439 .L1: ldx [%l4],%g2 C p16
441 sllx %g2,16,%g2 C align p16
442 add %i0,8,%i0 C res_ptr++
443 add %g2,%g1,%g1 C add p16 to p0 (ADD1)
451 EPILOGUE(mpn_sqr_diagonal)