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.

dot_sse_opteron.S 8.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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 12
  41. #define ARGS 0
  42. #define STACK_N 4 + STACK + ARGS(%esp)
  43. #define STACK_X 8 + STACK + ARGS(%esp)
  44. #define STACK_INCX 12 + STACK + ARGS(%esp)
  45. #define STACK_Y 16 + STACK + ARGS(%esp)
  46. #define STACK_INCY 20 + STACK + ARGS(%esp)
  47. #define N %ecx
  48. #define X %esi
  49. #define INCX %ebx
  50. #define Y %edi
  51. #define INCY %edx
  52. #define PREFETCHSIZE 84
  53. PROLOGUE
  54. pushl %edi
  55. pushl %esi
  56. pushl %ebx
  57. PROFCODE
  58. movl STACK_N, N
  59. movl STACK_X, X
  60. movl STACK_INCX, INCX
  61. movl STACK_Y, Y
  62. movl STACK_INCY, INCY
  63. #ifdef F_INTERFACE
  64. movl (N), N # N
  65. movl (INCX),INCX # INCX
  66. movl (INCY),INCY # INCY
  67. #endif
  68. leal (, INCX, SIZE), INCX
  69. leal (, INCY, SIZE), INCY
  70. pxor %xmm0, %xmm0
  71. pxor %xmm1, %xmm1
  72. pxor %xmm2, %xmm2
  73. pxor %xmm3, %xmm3
  74. cmpl $0, N
  75. jle .L999
  76. cmpl $SIZE, INCX
  77. jne .L50
  78. cmpl $SIZE, INCY
  79. jne .L50
  80. cmpl $3, N
  81. jle .L27
  82. testl $SIZE, Y
  83. je .L05
  84. movss 0 * SIZE(X), %xmm0
  85. mulss 0 * SIZE(Y), %xmm0
  86. addl $1 * SIZE, X
  87. addl $1 * SIZE, Y
  88. decl N
  89. ALIGN_2
  90. .L05:
  91. testl $2 * SIZE, Y
  92. je .L10
  93. movss 0 * SIZE(X), %xmm4
  94. movss 1 * SIZE(X), %xmm5
  95. mulss 0 * SIZE(Y), %xmm4
  96. mulss 1 * SIZE(Y), %xmm5
  97. addss %xmm4, %xmm1
  98. addss %xmm5, %xmm2
  99. addl $2 * SIZE, X
  100. addl $2 * SIZE, Y
  101. subl $2, N
  102. jle .L999
  103. ALIGN_2
  104. .L10:
  105. movl N, %eax
  106. sarl $5, %eax
  107. jle .L24
  108. movlps 0 * SIZE(X), %xmm4
  109. movhps 2 * SIZE(X), %xmm4
  110. movlps 4 * SIZE(X), %xmm5
  111. movhps 6 * SIZE(X), %xmm5
  112. movlps 8 * SIZE(X), %xmm6
  113. movhps 10 * SIZE(X), %xmm6
  114. movlps 12 * SIZE(X), %xmm7
  115. movhps 14 * SIZE(X), %xmm7
  116. mulps 0 * SIZE(Y), %xmm4
  117. mulps 4 * SIZE(Y), %xmm5
  118. mulps 8 * SIZE(Y), %xmm6
  119. mulps 12 * SIZE(Y), %xmm7
  120. decl %eax
  121. jle .L22
  122. ALIGN_3
  123. .L21:
  124. prefetch (PREFETCHSIZE + 0) * SIZE(Y)
  125. addps %xmm4, %xmm0
  126. movlps 16 * SIZE(X), %xmm4
  127. movhps 18 * SIZE(X), %xmm4
  128. addps %xmm5, %xmm1
  129. movlps 20 * SIZE(X), %xmm5
  130. movhps 22 * SIZE(X), %xmm5
  131. addps %xmm6, %xmm2
  132. movlps 24 * SIZE(X), %xmm6
  133. movhps 26 * SIZE(X), %xmm6
  134. addps %xmm7, %xmm3
  135. movlps 28 * SIZE(X), %xmm7
  136. movhps 30 * SIZE(X), %xmm7
  137. mulps 16 * SIZE(Y), %xmm4
  138. mulps 20 * SIZE(Y), %xmm5
  139. mulps 24 * SIZE(Y), %xmm6
  140. mulps 28 * SIZE(Y), %xmm7
  141. prefetch (PREFETCHSIZE + 16) * SIZE(Y)
  142. addps %xmm4, %xmm0
  143. movlps 32 * SIZE(X), %xmm4
  144. movhps 34 * SIZE(X), %xmm4
  145. addps %xmm5, %xmm1
  146. movlps 36 * SIZE(X), %xmm5
  147. movhps 38 * SIZE(X), %xmm5
  148. addps %xmm6, %xmm2
  149. movlps 40 * SIZE(X), %xmm6
  150. movhps 42 * SIZE(X), %xmm6
  151. addps %xmm7, %xmm3
  152. movlps 44 * SIZE(X), %xmm7
  153. movhps 46 * SIZE(X), %xmm7
  154. mulps 32 * SIZE(Y), %xmm4
  155. mulps 36 * SIZE(Y), %xmm5
  156. mulps 40 * SIZE(Y), %xmm6
  157. mulps 44 * SIZE(Y), %xmm7
  158. addl $32 * SIZE, X
  159. addl $32 * SIZE, Y
  160. decl %eax
  161. jg .L21
  162. ALIGN_3
  163. .L22:
  164. addps %xmm4, %xmm0
  165. movlps 16 * SIZE(X), %xmm4
  166. movhps 18 * SIZE(X), %xmm4
  167. addps %xmm5, %xmm1
  168. movlps 20 * SIZE(X), %xmm5
  169. movhps 22 * SIZE(X), %xmm5
  170. addps %xmm6, %xmm2
  171. movlps 24 * SIZE(X), %xmm6
  172. movhps 26 * SIZE(X), %xmm6
  173. addps %xmm7, %xmm3
  174. movlps 28 * SIZE(X), %xmm7
  175. movhps 30 * SIZE(X), %xmm7
  176. mulps 16 * SIZE(Y), %xmm4
  177. mulps 20 * SIZE(Y), %xmm5
  178. mulps 24 * SIZE(Y), %xmm6
  179. mulps 28 * SIZE(Y), %xmm7
  180. addps %xmm4, %xmm0
  181. addps %xmm5, %xmm1
  182. addps %xmm6, %xmm2
  183. addps %xmm7, %xmm3
  184. addl $32 * SIZE, X
  185. addl $32 * SIZE, Y
  186. ALIGN_3
  187. .L24:
  188. testl $31, N
  189. jle .L999
  190. testl $16, N
  191. jle .L25
  192. movlps 0 * SIZE(X), %xmm4
  193. movhps 2 * SIZE(X), %xmm4
  194. movlps 4 * SIZE(X), %xmm5
  195. movhps 6 * SIZE(X), %xmm5
  196. movlps 8 * SIZE(X), %xmm6
  197. movhps 10 * SIZE(X), %xmm6
  198. movlps 12 * SIZE(X), %xmm7
  199. movhps 14 * SIZE(X), %xmm7
  200. mulps 0 * SIZE(Y), %xmm4
  201. mulps 4 * SIZE(Y), %xmm5
  202. mulps 8 * SIZE(Y), %xmm6
  203. mulps 12 * SIZE(Y), %xmm7
  204. addps %xmm4, %xmm0
  205. addps %xmm5, %xmm1
  206. addps %xmm6, %xmm2
  207. addps %xmm7, %xmm3
  208. addl $16 * SIZE, X
  209. addl $16 * SIZE, Y
  210. ALIGN_3
  211. .L25:
  212. testl $8, N
  213. jle .L26
  214. movlps 0 * SIZE(X), %xmm4
  215. movhps 2 * SIZE(X), %xmm4
  216. movlps 4 * SIZE(X), %xmm5
  217. movhps 6 * SIZE(X), %xmm5
  218. mulps 0 * SIZE(Y), %xmm4
  219. mulps 4 * SIZE(Y), %xmm5
  220. addps %xmm4, %xmm0
  221. addps %xmm5, %xmm1
  222. addl $8 * SIZE, X
  223. addl $8 * SIZE, Y
  224. ALIGN_3
  225. .L26:
  226. testl $4, N
  227. jle .L27
  228. movlps 0 * SIZE(X), %xmm4
  229. movhps 2 * SIZE(X), %xmm4
  230. mulps 0 * SIZE(Y), %xmm4
  231. addps %xmm4, %xmm0
  232. addl $4 * SIZE, X
  233. addl $4 * SIZE, Y
  234. ALIGN_3
  235. .L27:
  236. testl $2, N
  237. jle .L28
  238. movss 0 * SIZE(X), %xmm4
  239. movss 1 * SIZE(X), %xmm5
  240. mulss 0 * SIZE(Y), %xmm4
  241. mulss 1 * SIZE(Y), %xmm5
  242. addss %xmm4, %xmm0
  243. addss %xmm5, %xmm1
  244. addl $2 * SIZE, X
  245. addl $2 * SIZE, Y
  246. ALIGN_3
  247. .L28:
  248. testl $1, N
  249. jle .L999
  250. movss 0 * SIZE(X), %xmm4
  251. mulss 0 * SIZE(Y), %xmm4
  252. addss %xmm4, %xmm0
  253. jmp .L999
  254. ALIGN_3
  255. .L50:
  256. #ifdef F_INTERFACE
  257. testl INCX, INCX
  258. jge .L51
  259. movl N, %eax
  260. decl %eax
  261. imull INCX, %eax
  262. subl %eax, X
  263. ALIGN_3
  264. .L51:
  265. testl INCY, INCY
  266. jge .L52
  267. movl N, %eax
  268. decl %eax
  269. imull INCY, %eax
  270. subl %eax, Y
  271. ALIGN_3
  272. .L52:
  273. #endif
  274. movl N, %eax
  275. sarl $2, %eax
  276. jle .L55
  277. ALIGN_3
  278. .L53:
  279. movss 0 * SIZE(X), %xmm4
  280. addl INCX, X
  281. mulss 0 * SIZE(Y), %xmm4
  282. addl INCY, Y
  283. movss 0 * SIZE(X), %xmm5
  284. addl INCX, X
  285. mulss 0 * SIZE(Y), %xmm5
  286. addl INCY, Y
  287. movss 0 * SIZE(X), %xmm6
  288. addl INCX, X
  289. mulss 0 * SIZE(Y), %xmm6
  290. addl INCY, Y
  291. movss 0 * SIZE(X), %xmm7
  292. addl INCX, X
  293. mulss 0 * SIZE(Y), %xmm7
  294. addl INCY, Y
  295. addss %xmm4, %xmm0
  296. addss %xmm5, %xmm1
  297. addss %xmm6, %xmm2
  298. addss %xmm7, %xmm3
  299. decl %eax
  300. jg .L53
  301. ALIGN_3
  302. .L55:
  303. movl N, %eax
  304. andl $3, %eax
  305. jle .L999
  306. ALIGN_3
  307. .L56:
  308. movss 0 * SIZE(X), %xmm4
  309. addl INCX, X
  310. mulss 0 * SIZE(Y), %xmm4
  311. addl INCY, Y
  312. addss %xmm4, %xmm0
  313. decl %eax
  314. jg .L56
  315. ALIGN_3
  316. .L999:
  317. addps %xmm1, %xmm0
  318. addps %xmm3, %xmm2
  319. addps %xmm2, %xmm0
  320. #if !defined(HAVE_SSE3) || defined(__INTERIX)
  321. movhlps %xmm0, %xmm1
  322. addps %xmm1, %xmm0
  323. pshufd $1, %xmm0, %xmm1
  324. addss %xmm1, %xmm0
  325. #else
  326. haddps %xmm0, %xmm0
  327. haddps %xmm0, %xmm0
  328. #endif
  329. movss %xmm0, STACK_N
  330. flds STACK_N
  331. popl %ebx
  332. popl %esi
  333. popl %edi
  334. ret
  335. EPILOGUE