nextafter_gen.S 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * Math library
  3. *
  4. * Copyright (C) 2016 Intel Corporation. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * * Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in
  14. * the documentation and/or other materials provided with the
  15. * distribution.
  16. * * Neither the name of Intel Corporation nor the names of its
  17. * contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. *
  33. * Author Name <jingwei.zhang@intel.com>
  34. * History:
  35. * 03-14-2016 Initial version. numerics svn rev. 12864
  36. */
  37. .file "nextafter_gen.c"
  38. .text
  39. ..TXTST0:
  40. # -- Begin nextafter
  41. .text
  42. .align 16,0x90
  43. .globl nextafter
  44. nextafter:
  45. # parameter 1: %xmm0
  46. # parameter 2: %xmm1
  47. ..B1.1:
  48. .cfi_startproc
  49. ..___tag_value_nextafter.1:
  50. ..L2:
  51. movsd %xmm0, -16(%rsp)
  52. movzwl -10(%rsp), %r8d
  53. andl $32752, %r8d
  54. shrl $4, %r8d
  55. movsd %xmm1, -8(%rsp)
  56. cmpl $2047, %r8d
  57. je ..B1.23
  58. ..B1.2:
  59. movzwl -2(%rsp), %edi
  60. andl $32752, %edi
  61. shrl $4, %edi
  62. cmpl $2047, %edi
  63. je ..B1.20
  64. ..B1.3:
  65. movsd -8(%rsp), %xmm0
  66. movsd -16(%rsp), %xmm1
  67. ucomisd %xmm0, %xmm1
  68. jp ..B1.4
  69. je ..B1.17
  70. ..B1.4:
  71. movl -12(%rsp), %edx
  72. movl %edx, %eax
  73. andl $2147483647, %eax
  74. orl -16(%rsp), %eax
  75. je ..B1.19
  76. ..B1.5:
  77. movl %edx, %eax
  78. movl -4(%rsp), %ecx
  79. xorl %ecx, %eax
  80. movq -16(%rsp), %rsi
  81. testl $-2147483648, %eax
  82. jne ..B1.11
  83. ..B1.6:
  84. cmpl %edi, %r8d
  85. jg ..B1.11
  86. ..B1.7:
  87. jne ..B1.12
  88. ..B1.8:
  89. andl $1048575, %edx
  90. andl $1048575, %ecx
  91. cmpl %ecx, %edx
  92. jg ..B1.11
  93. ..B1.9:
  94. jne ..B1.12
  95. ..B1.10:
  96. movl -16(%rsp), %eax
  97. cmpl -8(%rsp), %eax
  98. jbe ..B1.12
  99. ..B1.11:
  100. decq %rsi
  101. movq %rsi, -16(%rsp)
  102. jmp ..B1.13
  103. ..B1.12:
  104. incq %rsi
  105. movq %rsi, -16(%rsp)
  106. ..B1.13:
  107. movl -12(%rsp), %edx
  108. andl $2147483647, %edx
  109. lea -1048576(%rdx), %eax
  110. cmpl $2145386496, %eax
  111. jb ..B1.18
  112. ..B1.14:
  113. cmpl $1048576, %edx
  114. jae ..B1.16
  115. ..B1.15:
  116. lea _small_value_64(%rip), %rax
  117. movsd (%rax), %xmm0
  118. mulsd %xmm0, %xmm0
  119. movsd %xmm0, -24(%rsp)
  120. movsd -16(%rsp), %xmm0
  121. ret
  122. ..B1.16:
  123. lea _large_value_64(%rip), %rax
  124. movsd (%rax), %xmm0
  125. mulsd %xmm0, %xmm0
  126. movsd %xmm0, -24(%rsp)
  127. movsd -16(%rsp), %xmm0
  128. ..B1.17:
  129. ret
  130. ..B1.18:
  131. movsd -16(%rsp), %xmm0
  132. ret
  133. ..B1.19:
  134. movb -1(%rsp), %al
  135. lea _small_value_64(%rip), %rdi
  136. andb $-128, %al
  137. lea _smallest_value_64(%rip), %rdx
  138. shrb $7, %al
  139. movsd (%rdi), %xmm0
  140. mulsd %xmm0, %xmm0
  141. movzbl %al, %ecx
  142. movsd %xmm0, -24(%rsp)
  143. movq (%rdx,%rcx,8), %rsi
  144. movq %rsi, -16(%rsp)
  145. jmp ..B1.18
  146. ..B1.20:
  147. testl $1048575, -4(%rsp)
  148. jne ..B1.22
  149. ..B1.21:
  150. cmpl $0, -8(%rsp)
  151. je ..B1.3
  152. ..B1.22:
  153. movsd -16(%rsp), %xmm0
  154. addsd -8(%rsp), %xmm0
  155. ret
  156. ..B1.23:
  157. testl $1048575, -12(%rsp)
  158. jne ..B1.22
  159. ..B1.24:
  160. cmpl $0, -16(%rsp)
  161. jne ..B1.22
  162. jmp ..B1.2
  163. .align 16,0x90
  164. .cfi_endproc
  165. .type nextafter,@function
  166. .size nextafter,.-nextafter
  167. .data
  168. # -- End nextafter
  169. .section .rodata, "a"
  170. .align 4
  171. .align 4
  172. _small_value_64:
  173. .long 0
  174. .long 24117248
  175. .long 0
  176. .long 2171600896
  177. .type _small_value_64,@object
  178. .size _small_value_64,16
  179. .align 4
  180. _large_value_64:
  181. .long 0
  182. .long 2121269248
  183. .long 0
  184. .long 4268752896
  185. .type _large_value_64,@object
  186. .size _large_value_64,16
  187. .align 4
  188. _smallest_value_64:
  189. .long 1
  190. .long 0
  191. .long 1
  192. .long 2147483648
  193. .type _smallest_value_64,@object
  194. .size _smallest_value_64,16
  195. .data
  196. .section .note.GNU-stack, ""
  197. // -- Begin DWARF2 SEGMENT .eh_frame
  198. .section .eh_frame,"a",@progbits
  199. .eh_frame_seg:
  200. .align 1
  201. # End