remainder_gen.S 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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 "remainder_gen.c"
  38. .text
  39. ..TXTST0:
  40. # -- Begin remainder
  41. .text
  42. .align 16,0x90
  43. .globl remainder
  44. remainder:
  45. # parameter 1: %xmm0
  46. # parameter 2: %xmm1
  47. ..B1.1:
  48. .cfi_startproc
  49. ..___tag_value_remainder.1:
  50. ..L2:
  51. movq $0x7fffffffffffffff, %rdi
  52. movd %xmm0, %r9
  53. movq $0x7ff0000000000000, %rax
  54. movd %xmm1, %rdx
  55. movsd %xmm0, -32(%rsp)
  56. movsd %xmm1, -40(%rsp)
  57. andq %r9, %rdi
  58. btrq $63, %rdx
  59. movq $0x7ff0000000000000, %rcx
  60. andq %rdi, %rax
  61. andq %rdx, %rcx
  62. xorb %r8b, %r8b
  63. shrq $52, %rax
  64. shrq $52, %rcx
  65. addl $-1023, %eax
  66. movq %rdi, -16(%rsp)
  67. addl $-1023, %ecx
  68. movq %rdx, -8(%rsp)
  69. sarq $63, %r9
  70. movq $0, -24(%rsp)
  71. cmpl $1024, %eax
  72. movsd -16(%rsp), %xmm2
  73. movsd -8(%rsp), %xmm0
  74. je ..B1.5
  75. ..B1.2:
  76. cmpl $1024, %ecx
  77. je ..B1.5
  78. ..B1.3:
  79. testq %rdi, %rdi
  80. je ..B1.5
  81. ..B1.4:
  82. testq %rdx, %rdx
  83. jne ..B1.6
  84. ..B1.5:
  85. movb $1, %r8b
  86. ..B1.6:
  87. movq $0xfffffffffffff, %rsi
  88. andq %rsi, %rdi
  89. andq %rsi, %rdx
  90. testb %r8b, %r8b
  91. je ..B1.17
  92. ..B1.7:
  93. testq %rdi, %rdi
  94. je ..B1.9
  95. ..B1.8:
  96. cmpl $1024, %eax
  97. je ..B1.43
  98. ..B1.9:
  99. testq %rdx, %rdx
  100. je ..B1.11
  101. ..B1.10:
  102. cmpl $1024, %ecx
  103. je ..B1.44
  104. ..B1.11:
  105. movsd -24(%rsp), %xmm1
  106. ucomisd %xmm1, %xmm0
  107. jp ..B1.12
  108. je ..B1.45
  109. ..B1.12:
  110. movsd -24(%rsp), %xmm0
  111. ucomisd %xmm0, %xmm2
  112. jp ..B1.13
  113. je ..B1.15
  114. ..B1.13:
  115. testq %rdi, %rdi
  116. jne ..B1.15
  117. ..B1.14:
  118. cmpl $1024, %eax
  119. je ..B1.45
  120. ..B1.15:
  121. movsd -32(%rsp), %xmm0
  122. ..B1.16:
  123. ret
  124. ..B1.17:
  125. comisd %xmm2, %xmm0
  126. jb ..B1.23
  127. ..B1.18:
  128. ucomisd %xmm0, %xmm2
  129. jp ..B1.19
  130. je ..B1.57
  131. ..B1.19:
  132. cmpl $1023, %eax
  133. je ..B1.21
  134. ..B1.20:
  135. movaps %xmm2, %xmm1
  136. addsd %xmm2, %xmm1
  137. comisd %xmm1, %xmm0
  138. jae ..B1.22
  139. ..B1.21:
  140. testl %r9d, %r9d
  141. subsd %xmm0, %xmm2
  142. movaps %xmm2, %xmm0
  143. xorps .L_2il0floatpacket.1(%rip), %xmm0
  144. jne ..L3
  145. movaps %xmm2, %xmm0
  146. ..L3:
  147. ret
  148. ..B1.22:
  149. movsd -32(%rsp), %xmm0
  150. ret
  151. ..B1.23:
  152. cmpl $-1023, %eax
  153. je ..B1.53
  154. ..B1.24:
  155. movq $0x10000000000000, %r8
  156. orq %r8, %rdi
  157. ..B1.25:
  158. cmpl $-1023, %ecx
  159. je ..B1.49
  160. ..B1.26:
  161. movq $0x10000000000000, %r8
  162. orq %r8, %rdx
  163. ..B1.27:
  164. subl %ecx, %eax
  165. xorl %r8d, %r8d
  166. xorl %r11d, %r11d
  167. incl %eax
  168. je ..B1.31
  169. ..B1.28:
  170. movl $1, %r10d
  171. ..B1.29:
  172. movq %rdi, %r8
  173. incl %r11d
  174. subq %rdx, %r8
  175. cmpq %rdx, %rdi
  176. cmovae %r8, %rdi
  177. movl $0, %r8d
  178. cmovae %r10, %r8
  179. addq %rdi, %rdi
  180. cmpl %eax, %r11d
  181. jb ..B1.29
  182. ..B1.31:
  183. testq %rdi, %rdi
  184. je ..B1.58
  185. ..B1.32:
  186. shrq $1, %rdi
  187. cmpq %rsi, %rdi
  188. ja ..B1.36
  189. ..B1.34:
  190. addq %rdi, %rdi
  191. decl %ecx
  192. cmpq %rsi, %rdi
  193. jbe ..B1.34
  194. ..B1.36:
  195. cmpl $-1022, %ecx
  196. jl ..B1.38
  197. ..B1.37:
  198. movslq %ecx, %rcx
  199. andq %rdi, %rsi
  200. addq $1023, %rcx
  201. jmp ..B1.39
  202. ..B1.38:
  203. negl %ecx
  204. movq %rdi, %rsi
  205. addl $2, %ecx
  206. shrq %cl, %rsi
  207. xorl %ecx, %ecx
  208. ..B1.39:
  209. shlq $52, %rcx
  210. orq %rsi, %rcx
  211. movq %rcx, -40(%rsp)
  212. movsd -40(%rsp), %xmm2
  213. movaps %xmm2, %xmm1
  214. addsd %xmm2, %xmm1
  215. comisd %xmm0, %xmm1
  216. jb ..B1.42
  217. ..B1.40:
  218. ucomisd %xmm1, %xmm0
  219. jp ..B1.41
  220. je ..B1.48
  221. ..B1.41:
  222. subsd %xmm0, %xmm2
  223. ..B1.42:
  224. movaps %xmm2, %xmm0
  225. testl %r9d, %r9d
  226. xorps .L_2il0floatpacket.1(%rip), %xmm0
  227. jne ..L4
  228. movaps %xmm2, %xmm0
  229. ..L4:
  230. ret
  231. ..B1.43:
  232. movsd -32(%rsp), %xmm0
  233. mulsd .L_2il0floatpacket.0(%rip), %xmm0
  234. ret
  235. ..B1.44:
  236. movsd -40(%rsp), %xmm0
  237. mulsd .L_2il0floatpacket.0(%rip), %xmm0
  238. ret
  239. ..B1.45:
  240. movsd -24(%rsp), %xmm0
  241. movsd -24(%rsp), %xmm1
  242. divsd %xmm1, %xmm0
  243. ret
  244. ..B1.48:
  245. movaps %xmm2, %xmm0
  246. testq %r8, %r8
  247. xorps .L_2il0floatpacket.1(%rip), %xmm0
  248. je ..B1.42
  249. movaps %xmm0, %xmm2
  250. jmp ..B1.42
  251. ..B1.49:
  252. testq %rdx, %rdx
  253. je ..B1.26
  254. ..B1.50:
  255. movl $-1022, %ecx
  256. ..B1.51:
  257. addq %rdx, %rdx
  258. decl %ecx
  259. cmpq %rsi, %rdx
  260. jbe ..B1.51
  261. jmp ..B1.27
  262. ..B1.53:
  263. testq %rdi, %rdi
  264. je ..B1.24
  265. ..B1.54:
  266. movl $-1022, %eax
  267. ..B1.55:
  268. addq %rdi, %rdi
  269. decl %eax
  270. cmpq %rsi, %rdi
  271. jbe ..B1.55
  272. jmp ..B1.25
  273. ..B1.57:
  274. movsd -24(%rsp), %xmm0
  275. mulsd -32(%rsp), %xmm0
  276. ret
  277. ..B1.58:
  278. movsd -24(%rsp), %xmm0
  279. mulsd -32(%rsp), %xmm0
  280. movq %rdi, -40(%rsp)
  281. ret
  282. .align 16,0x90
  283. .cfi_endproc
  284. .type remainder,@function
  285. .size remainder,.-remainder
  286. .data
  287. # -- End remainder
  288. .section .rodata, "a"
  289. .align 16
  290. .align 16
  291. .L_2il0floatpacket.1:
  292. .long 0x00000000,0x80000000,0x00000000,0x00000000
  293. .type .L_2il0floatpacket.1,@object
  294. .size .L_2il0floatpacket.1,16
  295. .align 8
  296. .L_2il0floatpacket.0:
  297. .long 0x33333333,0x3ffb3333
  298. .type .L_2il0floatpacket.0,@object
  299. .size .L_2il0floatpacket.0,8
  300. .data
  301. .section .note.GNU-stack, ""
  302. // -- Begin DWARF2 SEGMENT .eh_frame
  303. .section .eh_frame,"a",@progbits
  304. .eh_frame_seg:
  305. .align 1
  306. # End
  307. .globl drem
  308. .equ drem, remainder