You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

nrm2_sse.S 8.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. /*********************************************************************/
  2. /* Copyright 2009, 2010 The University of Texas at Austin. */
  3. /* All rights reserved. */
  4. /* */
  5. /* Redistribution and use in source and binary forms, with or */
  6. /* without modification, are permitted provided that the following */
  7. /* conditions are met: */
  8. /* */
  9. /* 1. Redistributions of source code must retain the above */
  10. /* copyright notice, this list of conditions and the following */
  11. /* disclaimer. */
  12. /* */
  13. /* 2. Redistributions in binary form must reproduce the above */
  14. /* copyright notice, this list of conditions and the following */
  15. /* disclaimer in the documentation and/or other materials */
  16. /* provided with the distribution. */
  17. /* */
  18. /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
  19. /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
  20. /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
  21. /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
  22. /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
  23. /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
  24. /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
  25. /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
  26. /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
  27. /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
  28. /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
  29. /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
  30. /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
  31. /* POSSIBILITY OF SUCH DAMAGE. */
  32. /* */
  33. /* The views and conclusions contained in the software and */
  34. /* documentation are those of the authors and should not be */
  35. /* interpreted as representing official policies, either expressed */
  36. /* or implied, of The University of Texas at Austin. */
  37. /*********************************************************************/
  38. #define ASSEMBLER
  39. #include "common.h"
  40. #define STACK 8
  41. #define ARGS 0
  42. #define STACK_M 4 + STACK + ARGS(%esp)
  43. #define STACK_X 8 + STACK + ARGS(%esp)
  44. #define STACK_INCX 12 + STACK + ARGS(%esp)
  45. #define M %edx
  46. #define X %ecx
  47. #define INCX %esi
  48. #define I %eax
  49. #include "l1param.h"
  50. PROLOGUE
  51. PROFCODE
  52. pushl %esi
  53. pushl %ebx
  54. movl STACK_M, M
  55. movl STACK_X, X
  56. movl STACK_INCX, INCX
  57. pxor %xmm0, %xmm0
  58. testl M, M
  59. jle .L999
  60. pxor %xmm1, %xmm1
  61. testl INCX, INCX
  62. je .L999
  63. leal (, INCX, SIZE), INCX
  64. cmpl $SIZE, INCX
  65. jne .L40
  66. subl $-32 * SIZE, X
  67. testl $SIZE, X
  68. je .L05
  69. movss -32 * SIZE(X), %xmm0
  70. cvtss2sd %xmm0, %xmm0
  71. mulsd %xmm0, %xmm0
  72. addl INCX, X
  73. decl M
  74. jle .L998
  75. ALIGN_3
  76. .L05:
  77. movl M, I
  78. sarl $4, I
  79. jle .L13
  80. movsd -32 * SIZE(X), %xmm4
  81. movsd -30 * SIZE(X), %xmm5
  82. movsd -28 * SIZE(X), %xmm6
  83. movsd -26 * SIZE(X), %xmm7
  84. decl I
  85. jle .L12
  86. ALIGN_3
  87. .L10:
  88. #ifdef PREFETCH
  89. PREFETCH (PREFETCHSIZE + 0) - PREOFFSET(X)
  90. #endif
  91. cvtps2pd %xmm4, %xmm2
  92. movsd -24 * SIZE(X), %xmm4
  93. mulpd %xmm2, %xmm2
  94. addpd %xmm2, %xmm0
  95. cvtps2pd %xmm5, %xmm3
  96. movsd -22 * SIZE(X), %xmm5
  97. mulpd %xmm3, %xmm3
  98. addpd %xmm3, %xmm1
  99. cvtps2pd %xmm6, %xmm2
  100. movsd -20 * SIZE(X), %xmm6
  101. mulpd %xmm2, %xmm2
  102. addpd %xmm2, %xmm0
  103. cvtps2pd %xmm7, %xmm3
  104. movsd -18 * SIZE(X), %xmm7
  105. mulpd %xmm3, %xmm3
  106. addpd %xmm3, %xmm1
  107. cvtps2pd %xmm4, %xmm2
  108. movsd -16 * SIZE(X), %xmm4
  109. mulpd %xmm2, %xmm2
  110. addpd %xmm2, %xmm0
  111. cvtps2pd %xmm5, %xmm3
  112. movsd -14 * SIZE(X), %xmm5
  113. mulpd %xmm3, %xmm3
  114. addpd %xmm3, %xmm1
  115. cvtps2pd %xmm6, %xmm2
  116. movsd -12 * SIZE(X), %xmm6
  117. mulpd %xmm2, %xmm2
  118. addpd %xmm2, %xmm0
  119. cvtps2pd %xmm7, %xmm3
  120. movsd -10 * SIZE(X), %xmm7
  121. mulpd %xmm3, %xmm3
  122. addpd %xmm3, %xmm1
  123. subl $-16 * SIZE, X
  124. decl I
  125. jg .L10
  126. ALIGN_3
  127. .L12:
  128. cvtps2pd %xmm4, %xmm2
  129. movsd -24 * SIZE(X), %xmm4
  130. mulpd %xmm2, %xmm2
  131. addpd %xmm2, %xmm0
  132. cvtps2pd %xmm5, %xmm3
  133. movsd -22 * SIZE(X), %xmm5
  134. mulpd %xmm3, %xmm3
  135. addpd %xmm3, %xmm1
  136. cvtps2pd %xmm6, %xmm2
  137. movsd -20 * SIZE(X), %xmm6
  138. mulpd %xmm2, %xmm2
  139. addpd %xmm2, %xmm0
  140. cvtps2pd %xmm7, %xmm3
  141. movsd -18 * SIZE(X), %xmm7
  142. mulpd %xmm3, %xmm3
  143. addpd %xmm3, %xmm1
  144. cvtps2pd %xmm4, %xmm2
  145. mulpd %xmm2, %xmm2
  146. addpd %xmm2, %xmm0
  147. cvtps2pd %xmm5, %xmm3
  148. mulpd %xmm3, %xmm3
  149. addpd %xmm3, %xmm1
  150. cvtps2pd %xmm6, %xmm2
  151. mulpd %xmm2, %xmm2
  152. addpd %xmm2, %xmm0
  153. cvtps2pd %xmm7, %xmm3
  154. mulpd %xmm3, %xmm3
  155. addpd %xmm3, %xmm1
  156. subl $-16 * SIZE, X
  157. ALIGN_4
  158. .L13:
  159. testl $8, M
  160. je .L14
  161. movsd -32 * SIZE(X), %xmm4
  162. cvtps2pd %xmm4, %xmm2
  163. mulpd %xmm2, %xmm2
  164. addpd %xmm2, %xmm0
  165. movsd -30 * SIZE(X), %xmm5
  166. cvtps2pd %xmm5, %xmm3
  167. mulpd %xmm3, %xmm3
  168. addpd %xmm3, %xmm1
  169. movsd -28 * SIZE(X), %xmm6
  170. cvtps2pd %xmm6, %xmm2
  171. mulpd %xmm2, %xmm2
  172. addpd %xmm2, %xmm0
  173. movsd -26 * SIZE(X), %xmm7
  174. cvtps2pd %xmm7, %xmm3
  175. mulpd %xmm3, %xmm3
  176. addpd %xmm3, %xmm1
  177. addl $8 * SIZE, X
  178. ALIGN_3
  179. .L14:
  180. testl $4, M
  181. je .L15
  182. movsd -32 * SIZE(X), %xmm4
  183. cvtps2pd %xmm4, %xmm2
  184. mulpd %xmm2, %xmm2
  185. addpd %xmm2, %xmm0
  186. movsd -30 * SIZE(X), %xmm5
  187. cvtps2pd %xmm5, %xmm3
  188. mulpd %xmm3, %xmm3
  189. addpd %xmm3, %xmm1
  190. addl $4 * SIZE, X
  191. ALIGN_3
  192. .L15:
  193. testl $2, M
  194. je .L16
  195. movsd -32 * SIZE(X), %xmm4
  196. cvtps2pd %xmm4, %xmm2
  197. mulpd %xmm2, %xmm2
  198. addpd %xmm2, %xmm0
  199. addl $2 * SIZE, X
  200. ALIGN_3
  201. .L16:
  202. testl $1, M
  203. je .L998
  204. movss -32 * SIZE(X), %xmm4
  205. cvtss2sd %xmm4, %xmm2
  206. mulsd %xmm2, %xmm2
  207. addsd %xmm2, %xmm1
  208. jmp .L998
  209. ALIGN_4
  210. .L40:
  211. movl M, I
  212. sarl $3, I
  213. jle .L44
  214. ALIGN_4
  215. .L41:
  216. movss (X), %xmm4
  217. addl INCX, X
  218. cvtss2sd %xmm4, %xmm2
  219. mulsd %xmm2, %xmm2
  220. addsd %xmm2, %xmm0
  221. movss (X), %xmm5
  222. addl INCX, X
  223. cvtss2sd %xmm5, %xmm2
  224. mulsd %xmm2, %xmm2
  225. addsd %xmm2, %xmm1
  226. movss (X), %xmm6
  227. addl INCX, X
  228. cvtss2sd %xmm6, %xmm2
  229. mulsd %xmm2, %xmm2
  230. addsd %xmm2, %xmm0
  231. movss (X), %xmm7
  232. addl INCX, X
  233. cvtss2sd %xmm7, %xmm2
  234. mulsd %xmm2, %xmm2
  235. addsd %xmm2, %xmm1
  236. movss (X), %xmm4
  237. addl INCX, X
  238. cvtss2sd %xmm4, %xmm2
  239. mulsd %xmm2, %xmm2
  240. addsd %xmm2, %xmm0
  241. movss (X), %xmm5
  242. addl INCX, X
  243. cvtss2sd %xmm5, %xmm2
  244. mulsd %xmm2, %xmm2
  245. addsd %xmm2, %xmm1
  246. movss (X), %xmm6
  247. addl INCX, X
  248. cvtss2sd %xmm6, %xmm2
  249. mulsd %xmm2, %xmm2
  250. addsd %xmm2, %xmm0
  251. movss (X), %xmm7
  252. addl INCX, X
  253. cvtss2sd %xmm7, %xmm2
  254. mulsd %xmm2, %xmm2
  255. addsd %xmm2, %xmm1
  256. decl I
  257. jg .L41
  258. ALIGN_3
  259. .L44:
  260. testl $4, M
  261. je .L45
  262. movss (X), %xmm4
  263. addl INCX, X
  264. cvtss2sd %xmm4, %xmm2
  265. mulsd %xmm2, %xmm2
  266. addsd %xmm2, %xmm0
  267. movss (X), %xmm5
  268. addl INCX, X
  269. cvtss2sd %xmm5, %xmm2
  270. mulsd %xmm2, %xmm2
  271. addsd %xmm2, %xmm1
  272. movss (X), %xmm6
  273. addl INCX, X
  274. cvtss2sd %xmm6, %xmm2
  275. mulsd %xmm2, %xmm2
  276. addsd %xmm2, %xmm0
  277. movss (X), %xmm7
  278. addl INCX, X
  279. cvtss2sd %xmm7, %xmm2
  280. mulsd %xmm2, %xmm2
  281. addsd %xmm2, %xmm1
  282. ALIGN_3
  283. .L45:
  284. testl $2, M
  285. je .L46
  286. movss (X), %xmm4
  287. addl INCX, X
  288. cvtss2sd %xmm4, %xmm2
  289. mulsd %xmm2, %xmm2
  290. addsd %xmm2, %xmm0
  291. movss (X), %xmm5
  292. addl INCX, X
  293. cvtss2sd %xmm5, %xmm2
  294. mulsd %xmm2, %xmm2
  295. addsd %xmm2, %xmm1
  296. ALIGN_3
  297. .L46:
  298. testl $1, M
  299. je .L998
  300. movss (X), %xmm4
  301. cvtss2sd %xmm4, %xmm2
  302. mulsd %xmm2, %xmm2
  303. addsd %xmm2, %xmm0
  304. ALIGN_4
  305. .L998:
  306. addpd %xmm1, %xmm0
  307. #ifndef HAVE_SSE3
  308. movapd %xmm0, %xmm1
  309. unpckhpd %xmm0, %xmm0
  310. addsd %xmm1, %xmm0
  311. #else
  312. haddpd %xmm0, %xmm0
  313. #endif
  314. ALIGN_4
  315. .L999:
  316. sqrtsd %xmm0, %xmm0
  317. cvtsd2ss %xmm0, %xmm0
  318. movss %xmm0, STACK_M
  319. flds STACK_M
  320. popl %ebx
  321. popl %esi
  322. ret
  323. EPILOGUE