csqrtf.S 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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 "csqrtf.c"
  38. .text
  39. ..TXTST0:
  40. # -- Begin csqrtf
  41. .text
  42. .align 16,0x90
  43. .globl csqrtf
  44. csqrtf:
  45. # parameter 1: %xmm0
  46. ..B1.1:
  47. .cfi_startproc
  48. ..___tag_value_csqrtf.1:
  49. ..L2:
  50. ..B1.2:
  51. movq %rsp, %rax
  52. subq $120, %rsp
  53. .cfi_def_cfa_offset 128
  54. movq %rax, 24(%rsp)
  55. movss %xmm0, (%rsp)
  56. pshufd $1, %xmm0, %xmm1
  57. movss %xmm1, 8(%rsp)
  58. movq %rbx, 32(%rsp)
  59. movd (%rsp), %xmm0
  60. movd 8(%rsp), %xmm1
  61. movl (%rsp), %eax
  62. movl 8(%rsp), %ecx
  63. unpcklps %xmm1, %xmm0
  64. movl %ecx, %edx
  65. lea csqrtf_table(%rip), %r8
  66. andl $2139095040, %eax
  67. andl $2139095040, %ecx
  68. subl $8388608, %eax
  69. subl $8388608, %ecx
  70. andl $2139095040, %eax
  71. andl $2139095040, %ecx
  72. subl $2130706432, %eax
  73. subl $2130706432, %ecx
  74. testl %ecx, %eax
  75. jns .L_2TAG_PACKET_0.0.1
  76. cvtps2pd %xmm0, %xmm0
  77. pxor %xmm4, %xmm4
  78. movl $16, %eax
  79. movapd %xmm0, %xmm1
  80. unpckhpd %xmm1, %xmm1
  81. movapd %xmm0, %xmm7
  82. mulsd %xmm0, %xmm0
  83. movapd %xmm7, %xmm6
  84. mulsd %xmm1, %xmm1
  85. pinsrw $3, %eax, %xmm4
  86. addsd %xmm1, %xmm0
  87. andpd (%r8), %xmm7
  88. sqrtsd %xmm0, %xmm0
  89. addsd %xmm7, %xmm0
  90. psubd %xmm4, %xmm0
  91. movsd %xmm0, %xmm7
  92. movdqa %xmm0, %xmm1
  93. pand 16(%r8), %xmm0
  94. movdqa %xmm1, %xmm2
  95. paddd 32(%r8), %xmm0
  96. psrld $1, %xmm1
  97. psrlq $29, %xmm0
  98. pand 48(%r8), %xmm1
  99. rsqrtss %xmm0, %xmm0
  100. psubd 64(%r8), %xmm1
  101. psllq $29, %xmm0
  102. movapd 80(%r8), %xmm3
  103. psubd %xmm1, %xmm0
  104. movapd 96(%r8), %xmm1
  105. mulsd %xmm0, %xmm2
  106. movapd 48(%r8), %xmm4
  107. mulsd %xmm0, %xmm2
  108. subsd %xmm4, %xmm2
  109. mulsd %xmm2, %xmm3
  110. addsd %xmm1, %xmm3
  111. mulsd %xmm2, %xmm3
  112. mulsd %xmm0, %xmm3
  113. addsd %xmm3, %xmm0
  114. mulpd 112(%r8), %xmm7
  115. unpcklpd %xmm0, %xmm0
  116. .L_2TAG_PACKET_1.0.1:
  117. pextrw $3, %xmm6, %eax
  118. mulpd %xmm7, %xmm0
  119. andl $-2147483648, %edx
  120. cvtpd2ps %xmm0, %xmm1
  121. testl $32768, %eax
  122. pshufd $17, %xmm1, %xmm2
  123. je .L_2TAG_PACKET_2.0.1
  124. movd %xmm1, %ecx
  125. movd %xmm2, %eax
  126. orl %ecx, %edx
  127. testl $2139095040, %eax
  128. jmp .L_2TAG_PACKET_3.0.1
  129. .L_2TAG_PACKET_2.0.1:
  130. movd %xmm2, %ecx
  131. movd %xmm1, %eax
  132. orl %ecx, %edx
  133. testl $2139095040, %ecx
  134. .L_2TAG_PACKET_3.0.1:
  135. je .L_2TAG_PACKET_4.0.1
  136. shlq $32, %rdx
  137. orq %rdx, %rax
  138. shrq $32, %rdx
  139. movd %rax, %xmm0
  140. movq 32(%rsp), %rbx
  141. movq 24(%rsp), %rsp
  142. ret
  143. .L_2TAG_PACKET_4.0.1:
  144. testl $2147483647, 8(%rsp)
  145. jne .L_2TAG_PACKET_5.0.1
  146. shlq $32, %rdx
  147. orq %rdx, %rax
  148. shrq $32, %rdx
  149. movd %rax, %xmm0
  150. movq 32(%rsp), %rbx
  151. movq 24(%rsp), %rsp
  152. ret
  153. .L_2TAG_PACKET_5.0.1:
  154. pshufd $14, %xmm0, %xmm0
  155. mulsd %xmm0, %xmm0
  156. cvtsd2ss %xmm0, %xmm0
  157. shlq $32, %rdx
  158. orq %rdx, %rax
  159. shrq $32, %rdx
  160. movd %rax, %xmm0
  161. movq 32(%rsp), %rbx
  162. movq 24(%rsp), %rsp
  163. ret
  164. .L_2TAG_PACKET_0.0.1:
  165. movdqa %xmm0, %xmm2
  166. movdqa 128(%r8), %xmm4
  167. pshufd $80, %xmm0, %xmm0
  168. pxor %xmm5, %xmm5
  169. movdqa %xmm2, %xmm3
  170. pand 144(%r8), %xmm0
  171. pshufd $115, %xmm2, %xmm2
  172. pcmpeqd %xmm4, %xmm0
  173. movdqa %xmm2, %xmm6
  174. movmskps %xmm0, %eax
  175. pand %xmm2, %xmm4
  176. testl %eax, %eax
  177. jne .L_2TAG_PACKET_6.0.1
  178. pxor %xmm0, %xmm0
  179. .L_2TAG_PACKET_7.0.1:
  180. pand (%r8), %xmm2
  181. pcmpeqd %xmm5, %xmm4
  182. movdqa %xmm4, %xmm3
  183. pand 160(%r8), %xmm4
  184. psrlq $3, %xmm2
  185. pand 176(%r8), %xmm3
  186. por %xmm4, %xmm2
  187. paddd 192(%r8), %xmm3
  188. subpd %xmm4, %xmm2
  189. paddd %xmm3, %xmm2
  190. pandn %xmm2, %xmm0
  191. pxor %xmm4, %xmm4
  192. movl $16, %eax
  193. movapd %xmm0, %xmm1
  194. unpckhpd %xmm1, %xmm1
  195. movapd %xmm0, %xmm7
  196. mulsd %xmm0, %xmm0
  197. mulsd %xmm1, %xmm1
  198. pinsrw $3, %eax, %xmm4
  199. addsd %xmm1, %xmm0
  200. sqrtsd %xmm0, %xmm0
  201. addsd %xmm7, %xmm0
  202. psubd %xmm4, %xmm0
  203. movsd %xmm0, %xmm7
  204. sqrtsd %xmm0, %xmm1
  205. movapd 48(%r8), %xmm0
  206. divsd %xmm1, %xmm0
  207. mulpd 112(%r8), %xmm7
  208. unpcklpd %xmm0, %xmm0
  209. jmp .L_2TAG_PACKET_1.0.1
  210. .L_2TAG_PACKET_6.0.1:
  211. cmpl $5, %eax
  212. je .L_2TAG_PACKET_8.0.1
  213. testl $10, %eax
  214. jne .L_2TAG_PACKET_9.0.1
  215. pshufd $160, %xmm0, %xmm0
  216. jmp .L_2TAG_PACKET_7.0.1
  217. .L_2TAG_PACKET_8.0.1:
  218. xorl %eax, %eax
  219. andl $-2147483648, %edx
  220. shlq $32, %rdx
  221. orq %rdx, %rax
  222. shrq $32, %rdx
  223. movd %rax, %xmm0
  224. movq 32(%rsp), %rbx
  225. movq 24(%rsp), %rsp
  226. ret
  227. .L_2TAG_PACKET_9.0.1:
  228. movl %edx, %ecx
  229. andl $2147483647, %ecx
  230. movd %xmm3, %eax
  231. cmpl $2139095040, %ecx
  232. je .L_2TAG_PACKET_10.0.1
  233. ja .L_2TAG_PACKET_11.0.1
  234. andl $-2147483648, %edx
  235. cmpl $-8388608, %eax
  236. je .L_2TAG_PACKET_12.0.1
  237. cmpl $2139095040, %eax
  238. jne .L_2TAG_PACKET_13.0.1
  239. shlq $32, %rdx
  240. orq %rdx, %rax
  241. shrq $32, %rdx
  242. movd %rax, %xmm0
  243. movq 32(%rsp), %rbx
  244. movq 24(%rsp), %rsp
  245. ret
  246. .L_2TAG_PACKET_12.0.1:
  247. xorl %eax, %eax
  248. orl $2139095040, %edx
  249. shlq $32, %rdx
  250. orq %rdx, %rax
  251. shrq $32, %rdx
  252. movd %rax, %xmm0
  253. movq 32(%rsp), %rbx
  254. movq 24(%rsp), %rsp
  255. ret
  256. .L_2TAG_PACKET_11.0.1:
  257. cmpl $2139095040, %eax
  258. je .L_2TAG_PACKET_14.0.1
  259. cmpl $-8388608, %eax
  260. je .L_2TAG_PACKET_15.0.1
  261. .L_2TAG_PACKET_13.0.1:
  262. mulss %xmm3, %xmm1
  263. movss (%rsp), %xmm0
  264. mulss 8(%rsp), %xmm0
  265. movd %xmm1, %eax
  266. movl %eax, %edx
  267. shlq $32, %rdx
  268. orq %rdx, %rax
  269. shrq $32, %rdx
  270. movd %rax, %xmm0
  271. movq 32(%rsp), %rbx
  272. movq 24(%rsp), %rsp
  273. ret
  274. .L_2TAG_PACKET_14.0.1:
  275. movss 8(%rsp), %xmm0
  276. mulss %xmm0, %xmm0
  277. orl $4194304, %edx
  278. shlq $32, %rdx
  279. orq %rdx, %rax
  280. shrq $32, %rdx
  281. movd %rax, %xmm0
  282. movq 32(%rsp), %rbx
  283. movq 24(%rsp), %rsp
  284. ret
  285. .L_2TAG_PACKET_15.0.1:
  286. movss 8(%rsp), %xmm0
  287. mulss %xmm0, %xmm0
  288. movl %edx, %eax
  289. movl $2139095040, %edx
  290. orl $4194304, %eax
  291. shlq $32, %rdx
  292. orq %rdx, %rax
  293. shrq $32, %rdx
  294. movd %rax, %xmm0
  295. movq 32(%rsp), %rbx
  296. movq 24(%rsp), %rsp
  297. ret
  298. .L_2TAG_PACKET_10.0.1:
  299. movss (%rsp), %xmm0
  300. mulss 208(%r8), %xmm0
  301. movl $2139095040, %eax
  302. shlq $32, %rdx
  303. orq %rdx, %rax
  304. shrq $32, %rdx
  305. movd %rax, %xmm0
  306. movq 32(%rsp), %rbx
  307. movq 24(%rsp), %rsp
  308. ret
  309. .cfi_def_cfa_offset 8
  310. ..B1.3:
  311. .align 16,0x90
  312. .cfi_endproc
  313. .type csqrtf,@function
  314. .size csqrtf,.-csqrtf
  315. .data
  316. # -- End csqrtf
  317. .section .rodata, "a"
  318. .align 16
  319. .align 16
  320. csqrtf_table:
  321. .long 4294967295
  322. .long 2147483647
  323. .long 4294967295
  324. .long 2147483647
  325. .long 4294967295
  326. .long 2097151
  327. .long 4294967295
  328. .long 2097151
  329. .long 0
  330. .long 132120576
  331. .long 0
  332. .long 132120576
  333. .long 0
  334. .long 1072693248
  335. .long 0
  336. .long 1072693248
  337. .long 0
  338. .long 1475346432
  339. .long 0
  340. .long 1475346432
  341. .long 2148429837
  342. .long 1071120401
  343. .long 2148429837
  344. .long 1071120401
  345. .long 195330
  346. .long 3219128325
  347. .long 195330
  348. .long 3219128325
  349. .long 0
  350. .long 1072693248
  351. .long 0
  352. .long 1071644672
  353. .long 0
  354. .long 2139095040
  355. .long 0
  356. .long 2139095040
  357. .long 2147483647
  358. .long 2139095040
  359. .long 2147483647
  360. .long 2139095040
  361. .long 0
  362. .long 133169152
  363. .long 0
  364. .long 133169152
  365. .long 0
  366. .long 4162846720
  367. .long 0
  368. .long 4162846720
  369. .long 0
  370. .long 939524096
  371. .long 0
  372. .long 939524096
  373. .long 1065353216
  374. .long 1065353216
  375. .long 1065353216
  376. .long 1065353216
  377. .type csqrtf_table,@object
  378. .size csqrtf_table,224
  379. .data
  380. .section .note.GNU-stack, ""
  381. // -- Begin DWARF2 SEGMENT .eh_frame
  382. .section .eh_frame,"a",@progbits
  383. .eh_frame_seg:
  384. .align 1
  385. # End