Annotation of OpenXM_contrib/gmp/mpn/sparc32/v9/mul_1.asm, Revision 1.1.1.2
1.1.1.2 ! ohara 1: dnl SPARC v9 32-bit mpn_mul_1 -- Multiply a limb vector with a limb and store
! 2: dnl the result in a second limb vector.
1.1 maekawa 3:
1.1.1.2 ! ohara 4: dnl Copyright 1998, 2000, 2001 Free Software Foundation, Inc.
1.1 maekawa 5:
6: dnl This file is part of the GNU MP Library.
7:
8: dnl The GNU MP Library is free software; you can redistribute it and/or modify
9: dnl it under the terms of the GNU Lesser General Public License as published
10: dnl by the Free Software Foundation; either version 2.1 of the License, or (at
11: dnl your option) any later version.
12:
13: dnl The GNU MP Library is distributed in the hope that it will be useful, but
14: dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15: dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16: dnl License for more details.
17:
18: dnl You should have received a copy of the GNU Lesser General Public License
19: dnl along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20: dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21: dnl MA 02111-1307, USA.
22:
23: include(`../config.m4')
24:
1.1.1.2 ! ohara 25: C Algorithm: We use two floating-point multiplies per limb product, with the
! 26: C invariant v operand split into two 16-bit pieces, and the u operand split
! 27: C into 32-bit pieces. We convert the two 48-bit products and transfer them to
! 28: C the integer unit.
! 29:
! 30: C Speed: 7 cycles/limb on UltraSPARC-1/2.
! 31:
! 32: C Possible optimizations:
! 33: C 1. Combine 32-bit memory operations into 64-bit operations. Since we're
! 34: C memory bandwidth limited, this could save 1.5 cycles/limb.
! 35: C 2. Unroll the inner loop. Since we already use alternate temporary areas,
! 36: C it is very straightforward to unroll, using an exit branch midways.
! 37: C Unrolling would allow deeper scheduling which could improve speed for L2
! 38: C cache case.
! 39: C 3. For mpn_mul_1: Use more alternating temp areas. The std'es and ldx'es
! 40: C aren't sufficiently apart-scheduled with just two temp areas.
! 41: C 4. Do some cross-jumping to save about 1/2 the code size.
! 42: C 5. Specialize for particular v values. If its upper 16 bits are zero, we
! 43: C could save many operations.
1.1 maekawa 44:
1.1.1.2 ! ohara 45: C INPUT PARAMETERS
! 46: C rp i0
! 47: C up i1
! 48: C n i2
! 49: C v i3
1.1 maekawa 50:
1.1.1.2 ! ohara 51: define(`FSIZE',224)
1.1 maekawa 52:
1.1.1.2 ! ohara 53: ASM_START()
1.1 maekawa 54: PROLOGUE(mpn_mul_1)
1.1.1.2 ! ohara 55: add %sp, -FSIZE, %sp
! 56: sethi %hi(0xffff), %g1
! 57: srl %o3, 16, %g2
! 58: or %g1, %lo(0xffff), %g1
! 59: and %o3, %g1, %g1
! 60: stx %g1, [%sp+104]
! 61: stx %g2, [%sp+112]
! 62: ldd [%sp+104], %f6
! 63: ldd [%sp+112], %f8
! 64: fxtod %f6, %f6
! 65: fxtod %f8, %f8
! 66: ld [%sp+104], %f10 C zero f10
! 67:
! 68: mov 0, %g3 C cy = 0
! 69:
! 70: define(`fanop', `fitod %f18, %f0') C A quasi nop running in the FA pipe
! 71:
! 72: add %sp, 160, %o5 C point in scratch area
! 73: and %o5, -32, %o5 C align at 0 (mod 32) in scratch area
! 74:
! 75: subcc %o2, 1, %o2
! 76: ld [%o1], %f11 C read up[i]
! 77: add %o1, 4, %o1 C up++
! 78: bne,pt %icc, .L_two_or_more
! 79: fxtod %f10, %f2
! 80: .L_1: fmuld %f2, %f8, %f16
! 81: fmuld %f2, %f6, %f4
! 82: fdtox %f16, %f14
! 83: fdtox %f4, %f12
! 84: std %f14, [%o5+16]
! 85: std %f12, [%o5+24]
! 86: ldx [%o5+16], %g2 C p16
! 87: ldx [%o5+24], %g1 C p0
! 88: sllx %g2, 16, %g4 C (p16 << 16)
! 89: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 90: stw %g4, [%o0]
! 91: srlx %g4, 32, %g3 C new cy
! 92: mov %g3, %o0
! 93: retl
! 94: sub %sp, -FSIZE, %sp
! 95:
! 96: .align 16
! 97: .L_two_or_more:
! 98: subcc %o2, 1, %o2
! 99: ld [%o1], %f11 C read up[i]
! 100: fmuld %f2, %f8, %f16
! 101: fmuld %f2, %f6, %f4
! 102: add %o1, 4, %o1 C up++
! 103: bne,pt %icc, .L_three_or_more
! 104: fxtod %f10, %f2
! 105: .L_2: fdtox %f16, %f14
! 106: fdtox %f4, %f12
! 107: std %f14, [%o5+16]
! 108: fmuld %f2, %f8, %f16
! 109: std %f12, [%o5+24]
! 110: fmuld %f2, %f6, %f4
! 111: fdtox %f16, %f14
! 112: fdtox %f4, %f12
! 113: std %f14, [%o5+0]
! 114: std %f12, [%o5+8]
! 115: ldx [%o5+16], %g2 C p16
! 116: ldx [%o5+24], %g1 C p0
! 117: sllx %g2, 16, %g4 C (p16 << 16) * crossjmp pt
! 118: ldx [%o5+0], %g2 C p16
! 119: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 120: ldx [%o5+8], %g1 C p0
! 121: stw %g4, [%o0+0]
! 122: srlx %g4, 32, %g3 C new cy
! 123: sllx %g2, 16, %g4 C (p16 << 16)
! 124: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 125: add %g3, %g4, %g4 C p += cy
! 126: stw %g4, [%o0+4]
! 127: srlx %g4, 32, %g3 C new cy
! 128: mov %g3, %o0
! 129: retl
! 130: sub %sp, -FSIZE, %sp
! 131:
! 132: .align 16
! 133: .L_three_or_more:
! 134: subcc %o2, 1, %o2
! 135: ld [%o1], %f11 C read up[i]
! 136: fdtox %f16, %f14
! 137: fdtox %f4, %f12
! 138: std %f14, [%o5+16]
! 139: fmuld %f2, %f8, %f16
! 140: std %f12, [%o5+24]
! 141: fmuld %f2, %f6, %f4
! 142: add %o1, 4, %o1 C up++
! 143: bne,pt %icc, .L_four_or_more
! 144: fxtod %f10, %f2
! 145: .L_3: fdtox %f16, %f14
! 146: fdtox %f4, %f12
! 147: std %f14, [%o5+0]
! 148: fmuld %f2, %f8, %f16
! 149: std %f12, [%o5+8]
! 150: fmuld %f2, %f6, %f4
! 151: fdtox %f16, %f14
! 152: ldx [%o5+16], %g2 C p16
! 153: fdtox %f4, %f12
! 154: ldx [%o5+24], %g1 C p0
! 155: std %f14, [%o5+16]
! 156: std %f12, [%o5+24]
! 157: sllx %g2, 16, %g4 C (p16 << 16)
! 158: ldx [%o5+0], %g2 C p16
! 159: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 160: ldx [%o5+8], %g1 C p0
! 161: stw %g4, [%o0+0]
! 162: srlx %g4, 32, %g3 C new cy
! 163: sllx %g2, 16, %g4 C (p16 << 16)
! 164: ldx [%o5+16], %g2 C p16
! 165: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 166: ldx [%o5+24], %g1 C p0
! 167: add %g3, %g4, %g4 C p += cy
! 168: stw %g4, [%o0+4]
! 169: srlx %g4, 32, %g3 C new cy
! 170: sllx %g2, 16, %g4 C (p16 << 16)
! 171: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 172: add %g3, %g4, %g4 C p += cy
! 173: stw %g4, [%o0+8]
! 174: srlx %g4, 32, %g3 C new cy
! 175: mov %g3, %o0
! 176: retl
! 177: sub %sp, -FSIZE, %sp
! 178:
! 179: .align 16
! 180: .L_four_or_more:
! 181: subcc %o2, 1, %o2
! 182: ld [%o1], %f11 C read up[i]
! 183: fdtox %f16, %f14
! 184: fdtox %f4, %f12
! 185: std %f14, [%o5+0]
! 186: fmuld %f2, %f8, %f16
! 187: std %f12, [%o5+8]
! 188: fmuld %f2, %f6, %f4
! 189: add %o1, 4, %o1 C up++
! 190: bne,pt %icc, .L_five_or_more
! 191: fxtod %f10, %f2
! 192: .L_4: fdtox %f16, %f14
! 193: ldx [%o5+16], %g2 C p16
! 194: fdtox %f4, %f12
! 195: ldx [%o5+24], %g1 C p0
! 196: std %f14, [%o5+16]
! 197: fmuld %f2, %f8, %f16
! 198: std %f12, [%o5+24]
! 199: fmuld %f2, %f6, %f4
! 200: add %o1, 4, %o1 C up++
! 201: fdtox %f16, %f14
! 202: sllx %g2, 16, %g4 C (p16 << 16)
! 203: ldx [%o5+0], %g2 C p16
! 204: fdtox %f4, %f12
! 205: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 206: ldx [%o5+8], %g1 C p0
! 207: std %f14, [%o5+0]
! 208: std %f12, [%o5+8]
! 209: stw %g4, [%o0+0]
! 210: srlx %g4, 32, %g3 C new cy
! 211: sllx %g2, 16, %g4 C (p16 << 16)
! 212: ldx [%o5+16], %g2 C p16
! 213: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 214: ldx [%o5+24], %g1 C p0
! 215: add %g3, %g4, %g4 C p += cy
! 216: stw %g4, [%o0+4]
! 217: srlx %g4, 32, %g3 C new cy
! 218: sllx %g2, 16, %g4 C (p16 << 16)
! 219: ldx [%o5+0], %g2 C p16
! 220: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 221: ldx [%o5+8], %g1 C p0
! 222: add %g3, %g4, %g4 C p += cy
! 223: stw %g4, [%o0+8]
! 224: srlx %g4, 32, %g3 C new cy
! 225: sllx %g2, 16, %g4 C (p16 << 16)
! 226: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 227: add %g3, %g4, %g4 C p += cy
! 228: stw %g4, [%o0+12]
! 229: srlx %g4, 32, %g3 C new cy
! 230: mov %g3, %o0
! 231: retl
! 232: sub %sp, -FSIZE, %sp
! 233:
! 234: .align 16
! 235: .L_five_or_more:
! 236: subcc %o2, 1, %o2
! 237: ld [%o1], %f11 C read up[i]
! 238: fdtox %f16, %f14
! 239: ldx [%o5+16], %g2 C p16
! 240: fdtox %f4, %f12
! 241: ldx [%o5+24], %g1 C p0
! 242: std %f14, [%o5+16]
! 243: fmuld %f2, %f8, %f16
! 244: std %f12, [%o5+24]
! 245: fmuld %f2, %f6, %f4
! 246: add %o1, 4, %o1 C up++
! 247: bne,pt %icc, .Loop
! 248: fxtod %f10, %f2
! 249: b,a .L_out_5
1.1 maekawa 250:
1.1.1.2 ! ohara 251: C BEGIN MAIN LOOP
1.1 maekawa 252: .align 16
1.1.1.2 ! ohara 253: C -- 0
! 254: .Loop: nop
! 255: subcc %o2, 1, %o2
! 256: ld [%o1], %f11 C read up[i]
! 257: fdtox %f16, %f14
! 258: C -- 1
! 259: sllx %g2, 16, %g4 C (p16 << 16)
! 260: add %o0, 4, %o0 C rp++
! 261: ldx [%o5+0], %g2 C p16
! 262: fdtox %f4, %f12
! 263: C -- 2
! 264: nop
! 265: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 266: ldx [%o5+8], %g1 C p0
! 267: fanop
! 268: C -- 3
! 269: nop
! 270: add %g3, %g4, %g4 C p += cy
! 271: std %f14, [%o5+0]
! 272: fmuld %f2, %f8, %f16
! 273: C -- 4
! 274: srlx %g4, 32, %g3 C new cy
! 275: add %o1, 4, %o1 C up++
! 276: std %f12, [%o5+8]
! 277: fmuld %f2, %f6, %f4
! 278: C -- 5
! 279: xor %o5, 16, %o5 C alternate scratch variables
! 280: stw %g4, [%o0-4]
! 281: bne,pt %icc, .Loop
! 282: fxtod %f10, %f2
! 283: C -- 6
! 284:
! 285: C END MAIN LOOP
! 286:
! 287:
! 288: .L_out_5:
! 289: fdtox %f16, %f14
! 290: sllx %g2, 16, %g4 C (p16 << 16)
! 291: ldx [%o5+0], %g2 C p16
! 292: fdtox %f4, %f12
! 293: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 294: ldx [%o5+8], %g1 C p0
! 295: add %g4, %g3, %g4 C p += cy
! 296: std %f14, [%o5+0]
! 297: fmuld %f2, %f8, %f16
! 298: std %f12, [%o5+8]
! 299: fmuld %f2, %f6, %f4
! 300: xor %o5, 16, %o5
! 301: stw %g4, [%o0+0]
! 302: srlx %g4, 32, %g3 C new cy
! 303:
! 304: fdtox %f16, %f14
! 305: sllx %g2, 16, %g4 C (p16 << 16)
! 306: ldx [%o5+0], %g2 C p16
! 307: fdtox %f4, %f12
! 308: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 309: ldx [%o5+8], %g1 C p0
! 310: add %g3, %g4, %g4 C p += cy
! 311: std %f14, [%o5+0]
! 312: std %f12, [%o5+8]
! 313: xor %o5, 16, %o5
! 314: stw %g4, [%o0+4]
! 315: srlx %g4, 32, %g3 C new cy
! 316:
! 317: sllx %g2, 16, %g4 C (p16 << 16)
! 318: ldx [%o5+0], %g2 C p16
! 319: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 320: ldx [%o5+8], %g1 C p0
! 321: add %g3, %g4, %g4 C p += cy
! 322: xor %o5, 16, %o5
! 323: stw %g4, [%o0+8]
! 324: srlx %g4, 32, %g3 C new cy
! 325:
! 326: sllx %g2, 16, %g4 C (p16 << 16)
! 327: ldx [%o5+0], %g2 C p16
! 328: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 329: ldx [%o5+8], %g1 C p0
! 330: add %g3, %g4, %g4 C p += cy
! 331: stw %g4, [%o0+12]
! 332: srlx %g4, 32, %g3 C new cy
! 333:
! 334: sllx %g2, 16, %g4 C (p16 << 16)
! 335: add %g1, %g4, %g4 C p = p0 + (p16 << 16)
! 336: add %g3, %g4, %g4 C p += cy
! 337: stw %g4, [%o0+16]
! 338: srlx %g4, 32, %g3 C new cy
! 339:
! 340: mov %g3, %o0
! 341: retl
! 342: sub %sp, -FSIZE, %sp
1.1 maekawa 343: EPILOGUE(mpn_mul_1)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>