scalb_gen.S 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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 "scalb_gen.c"
  38. .text
  39. ..TXTST0:
  40. # -- Begin scalb
  41. .text
  42. .align 16,0x90
  43. .globl scalb
  44. scalb:
  45. # parameter 1: %xmm0
  46. # parameter 2: %xmm1
  47. ..B1.1:
  48. .cfi_startproc
  49. ..___tag_value_scalb.1:
  50. ..L2:
  51. movaps %xmm1, %xmm2
  52. movsd %xmm0, -16(%rsp)
  53. movzwl -10(%rsp), %eax
  54. movl %eax, %edx
  55. movsd %xmm2, -8(%rsp)
  56. andl $32752, %edx
  57. movzwl -2(%rsp), %ecx
  58. andl $32752, %ecx
  59. shrl $4, %edx
  60. shrl $4, %ecx
  61. cmpl $2047, %edx
  62. je ..B1.56
  63. ..B1.2:
  64. cmpl $2047, %ecx
  65. je ..B1.37
  66. ..B1.3:
  67. cmpl $1023, %ecx
  68. jl ..B1.20
  69. ..B1.4:
  70. cmpl $1044, %ecx
  71. jge ..B1.7
  72. ..B1.5:
  73. lea _TWO_52H(%rip), %rcx
  74. pxor %xmm1, %xmm1
  75. movsd (%rcx), %xmm0
  76. addsd %xmm2, %xmm0
  77. movsd %xmm0, -24(%rsp)
  78. movl -24(%rsp), %edi
  79. cvtsi2sd %edi, %xmm1
  80. ucomisd %xmm2, %xmm1
  81. jp ..B1.6
  82. je ..B1.10
  83. ..B1.6:
  84. lea _infs(%rip), %rax
  85. lea _zeros(%rip), %rdx
  86. movsd (%rax), %xmm0
  87. mulsd (%rdx), %xmm0
  88. ret
  89. ..B1.7:
  90. movb -1(%rsp), %sil
  91. lea large_integers(%rip), %rdi
  92. andb $-128, %sil
  93. shrb $7, %sil
  94. movzbl %sil, %r8d
  95. cmpl $1075, %ecx
  96. movl (%rdi,%r8,4), %edi
  97. jge ..B1.10
  98. ..B1.8:
  99. addl $13, %ecx
  100. movl -8(%rsp), %esi
  101. shll %cl, %esi
  102. testl %esi, %esi
  103. jne ..B1.6
  104. ..B1.10:
  105. testl %edx, %edx
  106. jne ..B1.15
  107. ..B1.11:
  108. testl $1048575, -12(%rsp)
  109. jne ..B1.14
  110. ..B1.12:
  111. cmpl $0, -16(%rsp)
  112. jne ..B1.14
  113. ..B1.13:
  114. movsd -16(%rsp), %xmm0
  115. ret
  116. ..B1.14:
  117. lea _TWO_55(%rip), %rax
  118. movsd -16(%rsp), %xmm0
  119. mulsd (%rax), %xmm0
  120. movsd %xmm0, -16(%rsp)
  121. movzwl -10(%rsp), %eax
  122. movl %eax, %edx
  123. andl $32752, %edx
  124. shrl $4, %edx
  125. addl $-55, %edx
  126. ..B1.15:
  127. movl $65536, %ecx
  128. cmpl $65536, %edi
  129. cmovg %ecx, %edi
  130. movl $-65536, %esi
  131. cmpl $-65536, %edi
  132. cmovge %edi, %esi
  133. lea (%rdx,%rsi), %ecx
  134. testl %ecx, %ecx
  135. jle ..B1.33
  136. ..B1.16:
  137. cmpl $2047, %ecx
  138. jl ..B1.18
  139. ..B1.17:
  140. movb -9(%rsp), %al
  141. lea _large_value_64(%rip), %rcx
  142. andb $-128, %al
  143. shrb $7, %al
  144. movzbl %al, %edx
  145. movsd (%rcx,%rdx,8), %xmm0
  146. mulsd (%rcx), %xmm0
  147. ret
  148. ..B1.18:
  149. andl $2047, %ecx
  150. andl $-32753, %eax
  151. shll $4, %ecx
  152. orl %ecx, %eax
  153. movw %ax, -10(%rsp)
  154. movsd -16(%rsp), %xmm0
  155. ..B1.19:
  156. ret
  157. ..B1.20:
  158. testl %ecx, %ecx
  159. jne ..B1.24
  160. ..B1.21:
  161. testl $1048575, -4(%rsp)
  162. jne ..B1.24
  163. ..B1.22:
  164. cmpl $0, -8(%rsp)
  165. jne ..B1.24
  166. ..B1.23:
  167. lea _ones(%rip), %rax
  168. movsd -16(%rsp), %xmm0
  169. mulsd (%rax), %xmm0
  170. ret
  171. ..B1.24:
  172. cmpl $2047, %edx
  173. jne ..B1.6
  174. ..B1.25:
  175. testl %ecx, %ecx
  176. jle ..B1.6
  177. ..B1.26:
  178. cmpl $1, %ecx
  179. jne ..B1.30
  180. ..B1.27:
  181. movl -4(%rsp), %eax
  182. andl $1048575, %eax
  183. ..B1.28:
  184. jne ..B1.30
  185. ..B1.29:
  186. cmpl $0, -8(%rsp)
  187. jbe ..B1.6
  188. ..B1.30:
  189. movb -9(%rsp), %al
  190. lea _infs(%rip), %rdx
  191. andb $-128, %al
  192. shrb $7, %al
  193. movzbl %al, %ecx
  194. movsd (%rdx,%rcx,8), %xmm0
  195. ret
  196. ..B1.33:
  197. cmpl $-52, %ecx
  198. jge ..B1.35
  199. ..B1.34:
  200. movb -9(%rsp), %al
  201. lea _small_value_64(%rip), %rcx
  202. andb $-128, %al
  203. shrb $7, %al
  204. movzbl %al, %edx
  205. movsd (%rcx,%rdx,8), %xmm0
  206. mulsd (%rcx), %xmm0
  207. ret
  208. ..B1.35:
  209. andl $-32753, %eax
  210. lea 55(%rdx,%rsi), %edx
  211. andl $2047, %edx
  212. shll $4, %edx
  213. orl %edx, %eax
  214. movw %ax, -10(%rsp)
  215. lea 8+_TWO_55(%rip), %rax
  216. movsd -16(%rsp), %xmm0
  217. mulsd (%rax), %xmm0
  218. ..B1.36:
  219. ret
  220. ..B1.37:
  221. testl $1048575, -4(%rsp)
  222. jne ..B1.51
  223. ..B1.38:
  224. cmpl $0, -8(%rsp)
  225. jne ..B1.51
  226. ..B1.39:
  227. testl %edx, %edx
  228. jne ..B1.46
  229. ..B1.40:
  230. testl $1048575, -12(%rsp)
  231. jne ..B1.47
  232. ..B1.41:
  233. cmpl $0, -16(%rsp)
  234. jne ..B1.47
  235. ..B1.42:
  236. testb $-128, -1(%rsp)
  237. je ..B1.44
  238. ..B1.43:
  239. movsd -16(%rsp), %xmm0
  240. ret
  241. ..B1.44:
  242. lea _infs(%rip), %rax
  243. lea _zeros(%rip), %rdx
  244. movsd (%rax), %xmm0
  245. mulsd (%rdx), %xmm0
  246. ..B1.45:
  247. ret
  248. ..B1.46:
  249. cmpl $2047, %edx
  250. je ..B1.52
  251. ..B1.47:
  252. movb -9(%rsp), %al
  253. andb $-128, %al
  254. shrb $7, %al
  255. movzbl %al, %edx
  256. testb $-128, -1(%rsp)
  257. je ..B1.49
  258. ..B1.48:
  259. lea _zeros(%rip), %rax
  260. movsd (%rax,%rdx,8), %xmm0
  261. ret
  262. ..B1.49:
  263. lea _infs(%rip), %rax
  264. movsd (%rax,%rdx,8), %xmm0
  265. ..B1.50:
  266. ret
  267. ..B1.51:
  268. movsd -16(%rsp), %xmm0
  269. addsd -8(%rsp), %xmm0
  270. ret
  271. ..B1.52:
  272. testb $-128, -1(%rsp)
  273. jne ..B1.54
  274. ..B1.53:
  275. movsd -16(%rsp), %xmm0
  276. ret
  277. ..B1.54:
  278. lea _infs(%rip), %rax
  279. lea _zeros(%rip), %rdx
  280. movsd (%rax), %xmm0
  281. mulsd (%rdx), %xmm0
  282. ..B1.55:
  283. ret
  284. ..B1.56:
  285. testl $1048575, -12(%rsp)
  286. jne ..B1.51
  287. ..B1.57:
  288. cmpl $0, -16(%rsp)
  289. jne ..B1.51
  290. ..B1.58:
  291. cmpl $2047, %ecx
  292. je ..B1.37
  293. jmp ..B1.20
  294. .align 16,0x90
  295. .cfi_endproc
  296. .type scalb,@function
  297. .size scalb,.-scalb
  298. .data
  299. # -- End scalb
  300. .section .rodata, "a"
  301. .align 4
  302. .align 4
  303. _TWO_52H:
  304. .long 0
  305. .long 1127743488
  306. .type _TWO_52H,@object
  307. .size _TWO_52H,8
  308. .align 4
  309. _infs:
  310. .long 0
  311. .long 2146435072
  312. .long 0
  313. .long 4293918720
  314. .type _infs,@object
  315. .size _infs,16
  316. .align 4
  317. _zeros:
  318. .long 0
  319. .long 0
  320. .long 0
  321. .long 2147483648
  322. .type _zeros,@object
  323. .size _zeros,16
  324. .align 4
  325. large_integers:
  326. .long 65536
  327. .long -65536
  328. .type large_integers,@object
  329. .size large_integers,8
  330. .align 4
  331. _TWO_55:
  332. .long 0
  333. .long 1130364928
  334. .long 0
  335. .long 1015021568
  336. .type _TWO_55,@object
  337. .size _TWO_55,16
  338. .align 4
  339. _large_value_64:
  340. .long 0
  341. .long 2121269248
  342. .long 0
  343. .long 4268752896
  344. .type _large_value_64,@object
  345. .size _large_value_64,16
  346. .align 4
  347. _ones:
  348. .long 0
  349. .long 1072693248
  350. .long 0
  351. .long 3220176896
  352. .type _ones,@object
  353. .size _ones,16
  354. .align 4
  355. _small_value_64:
  356. .long 0
  357. .long 24117248
  358. .long 0
  359. .long 2171600896
  360. .type _small_value_64,@object
  361. .size _small_value_64,16
  362. .data
  363. .section .note.GNU-stack, ""
  364. // -- Begin DWARF2 SEGMENT .eh_frame
  365. .section .eh_frame,"a",@progbits
  366. .eh_frame_seg:
  367. .align 1
  368. # End