nexttoward_gen.S 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 "nexttoward_gen.c"
  38. .text
  39. ..TXTST0:
  40. # -- Begin nexttoward
  41. .text
  42. .align 16,0x90
  43. .globl nexttoward
  44. nexttoward:
  45. # parameter 1: %xmm0
  46. # parameter 2: 8 + %rsp
  47. ..B1.1:
  48. .cfi_startproc
  49. ..___tag_value_nexttoward.1:
  50. ..L2:
  51. movsd %xmm0, -8(%rsp)
  52. movzwl -2(%rsp), %eax
  53. andl $32752, %eax
  54. cmpl $32752, %eax
  55. je ..B1.22
  56. ..B1.2:
  57. movzwl 16(%rsp), %esi
  58. andl $32767, %esi
  59. cmpl $32767, %esi
  60. je ..B1.20
  61. ..B1.3:
  62. fldl -8(%rsp)
  63. fldt 8(%rsp)
  64. fucomi %st(1), %st
  65. jp ..B1.4
  66. je ..B1.24
  67. ..B1.4:
  68. fstp %st(0)
  69. movl -4(%rsp), %eax
  70. andl $2147483647, %eax
  71. orl -8(%rsp), %eax
  72. je ..B1.19
  73. ..B1.5:
  74. fstpt -24(%rsp)
  75. movb -15(%rsp), %dl
  76. movb 17(%rsp), %al
  77. andb $-128, %dl
  78. andb $-128, %al
  79. shrb $7, %dl
  80. shrb $7, %al
  81. movq -8(%rsp), %rcx
  82. cmpb %dl, %al
  83. jne ..B1.11
  84. ..B1.6:
  85. movzwl -16(%rsp), %eax
  86. andl $32767, %eax
  87. cmpl %esi, %eax
  88. jg ..B1.11
  89. ..B1.7:
  90. jne ..B1.12
  91. ..B1.8:
  92. movl -20(%rsp), %eax
  93. movl 12(%rsp), %edx
  94. cmpl %edx, %eax
  95. ja ..B1.11
  96. ..B1.9:
  97. jne ..B1.12
  98. ..B1.10:
  99. movl -24(%rsp), %eax
  100. cmpl 8(%rsp), %eax
  101. jbe ..B1.12
  102. ..B1.11:
  103. decq %rcx
  104. movq %rcx, -40(%rsp)
  105. jmp ..B1.13
  106. ..B1.12:
  107. incq %rcx
  108. movq %rcx, -40(%rsp)
  109. ..B1.13:
  110. movl -36(%rsp), %edx
  111. andl $2147483647, %edx
  112. lea -1048576(%rdx), %eax
  113. cmpl $2145386496, %eax
  114. jb ..B1.18
  115. ..B1.14:
  116. cmpl $1048576, %edx
  117. jae ..B1.16
  118. ..B1.15:
  119. lea _small_value_64(%rip), %rax
  120. movsd (%rax), %xmm0
  121. mulsd %xmm0, %xmm0
  122. movsd %xmm0, -32(%rsp)
  123. movsd -40(%rsp), %xmm0
  124. ret
  125. ..B1.16:
  126. lea _large_value_64(%rip), %rax
  127. movsd (%rax), %xmm0
  128. mulsd %xmm0, %xmm0
  129. movsd %xmm0, -32(%rsp)
  130. movsd -40(%rsp), %xmm0
  131. ..B1.17:
  132. ret
  133. ..B1.18:
  134. movsd -40(%rsp), %xmm0
  135. ret
  136. ..B1.19:
  137. fstp %st(0)
  138. movb 17(%rsp), %al
  139. lea _small_value_64(%rip), %rdi
  140. andb $-128, %al
  141. lea _smallest_value_64(%rip), %rdx
  142. shrb $7, %al
  143. movsd (%rdi), %xmm0
  144. mulsd %xmm0, %xmm0
  145. movzbl %al, %ecx
  146. movsd %xmm0, -32(%rsp)
  147. movq (%rdx,%rcx,8), %rsi
  148. movq %rsi, -40(%rsp)
  149. jmp ..B1.18
  150. ..B1.20:
  151. movq $0x8000000000000000, %rax
  152. cmpq 8(%rsp), %rax
  153. je ..B1.3
  154. ..B1.21:
  155. fldl -8(%rsp)
  156. fldt 8(%rsp)
  157. fmulp %st, %st(1)
  158. fstpl -40(%rsp)
  159. movsd -40(%rsp), %xmm0
  160. ret
  161. ..B1.22:
  162. testl $1048575, -4(%rsp)
  163. jne ..B1.21
  164. ..B1.23:
  165. cmpl $0, -8(%rsp)
  166. jne ..B1.21
  167. jmp ..B1.2
  168. ..B1.24:
  169. fstp %st(1)
  170. fstpl -40(%rsp)
  171. movsd -40(%rsp), %xmm0
  172. ret
  173. .align 16,0x90
  174. .cfi_endproc
  175. .type nexttoward,@function
  176. .size nexttoward,.-nexttoward
  177. .data
  178. # -- End nexttoward
  179. .section .rodata, "a"
  180. .align 4
  181. .align 4
  182. _small_value_64:
  183. .long 0
  184. .long 24117248
  185. .long 0
  186. .long 2171600896
  187. .type _small_value_64,@object
  188. .size _small_value_64,16
  189. .align 4
  190. _large_value_64:
  191. .long 0
  192. .long 2121269248
  193. .long 0
  194. .long 4268752896
  195. .type _large_value_64,@object
  196. .size _large_value_64,16
  197. .align 4
  198. _smallest_value_64:
  199. .long 1
  200. .long 0
  201. .long 1
  202. .long 2147483648
  203. .type _smallest_value_64,@object
  204. .size _smallest_value_64,16
  205. .data
  206. .section .note.GNU-stack, ""
  207. // -- Begin DWARF2 SEGMENT .eh_frame
  208. .section .eh_frame,"a",@progbits
  209. .eh_frame_seg:
  210. .align 1
  211. # End