add_n.S 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # Alpha __mpn_add_n -- Add two limb vectors of the same length > 0 and
  2. # store sum in a third limb vector.
  3. # Copyright (C) 1995-2026 Free Software Foundation, Inc.
  4. # This file is part of the GNU MP Library.
  5. # The GNU MP Library is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU Lesser General Public License as published by
  7. # the Free Software Foundation; either version 2.1 of the License, or (at your
  8. # option) any later version.
  9. # The GNU MP Library is distributed in the hope that it will be useful, but
  10. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  12. # License for more details.
  13. # You should have received a copy of the GNU Lesser General Public License
  14. # along with the GNU MP Library. If not, see <https://www.gnu.org/licenses/>.
  15. # INPUT PARAMETERS
  16. # res_ptr $16
  17. # s1_ptr $17
  18. # s2_ptr $18
  19. # size $19
  20. .set noreorder
  21. .set noat
  22. .text
  23. .align 3
  24. .globl __mpn_add_n
  25. .ent __mpn_add_n
  26. __mpn_add_n:
  27. .frame $30,0,$26,0
  28. ldq $3,0($17)
  29. ldq $4,0($18)
  30. subq $19,1,$19
  31. and $19,4-1,$2 # number of limbs in first loop
  32. bis $31,$31,$0
  33. beq $2,.L0 # if multiple of 4 limbs, skip first loop
  34. subq $19,$2,$19
  35. .Loop0: subq $2,1,$2
  36. ldq $5,8($17)
  37. addq $4,$0,$4
  38. ldq $6,8($18)
  39. cmpult $4,$0,$1
  40. addq $3,$4,$4
  41. cmpult $4,$3,$0
  42. stq $4,0($16)
  43. or $0,$1,$0
  44. addq $17,8,$17
  45. addq $18,8,$18
  46. bis $5,$5,$3
  47. bis $6,$6,$4
  48. addq $16,8,$16
  49. bne $2,.Loop0
  50. .L0: beq $19,.Lend
  51. .align 3
  52. .Loop: subq $19,4,$19
  53. ldq $5,8($17)
  54. addq $4,$0,$4
  55. ldq $6,8($18)
  56. cmpult $4,$0,$1
  57. addq $3,$4,$4
  58. cmpult $4,$3,$0
  59. stq $4,0($16)
  60. or $0,$1,$0
  61. ldq $3,16($17)
  62. addq $6,$0,$6
  63. ldq $4,16($18)
  64. cmpult $6,$0,$1
  65. addq $5,$6,$6
  66. cmpult $6,$5,$0
  67. stq $6,8($16)
  68. or $0,$1,$0
  69. ldq $5,24($17)
  70. addq $4,$0,$4
  71. ldq $6,24($18)
  72. cmpult $4,$0,$1
  73. addq $3,$4,$4
  74. cmpult $4,$3,$0
  75. stq $4,16($16)
  76. or $0,$1,$0
  77. ldq $3,32($17)
  78. addq $6,$0,$6
  79. ldq $4,32($18)
  80. cmpult $6,$0,$1
  81. addq $5,$6,$6
  82. cmpult $6,$5,$0
  83. stq $6,24($16)
  84. or $0,$1,$0
  85. addq $17,32,$17
  86. addq $18,32,$18
  87. addq $16,32,$16
  88. bne $19,.Loop
  89. .Lend: addq $4,$0,$4
  90. cmpult $4,$0,$1
  91. addq $3,$4,$4
  92. cmpult $4,$3,$0
  93. stq $4,0($16)
  94. or $0,$1,$0
  95. ret $31,($26),1
  96. .end __mpn_add_n