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.

zgemv_t_sse2.S 8.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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. #ifdef PENTIUM4
  41. #define PREFETCH prefetcht0
  42. #define PREFETCHW prefetcht0
  43. #define PREFETCHSIZE (8 * 2)
  44. #endif
  45. #if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON) || defined(NEHALEM) || defined(SANDYBRIDGE)
  46. #define PREFETCH prefetcht0
  47. #define PREFETCHW prefetcht0
  48. #define PREFETCHSIZE (8 * 7)
  49. #endif
  50. #ifdef OPTERON
  51. #define PREFETCH prefetchnta
  52. #define PREFETCHW prefetchw
  53. #define PREFETCHSIZE (8 * 3)
  54. #define movsd movlps
  55. #endif
  56. #if defined(BARCELONA) || defined(BULLDOZER)
  57. #define PREFETCH prefetchnta
  58. #define PREFETCHW prefetchw
  59. #define PREFETCHSIZE (8 * 5)
  60. #endif
  61. #ifdef ATOM
  62. #define PREFETCH prefetchnta
  63. #define PREFETCHW prefetcht0
  64. #define PREFETCHSIZE (8 * 6)
  65. #endif
  66. #ifdef NANO
  67. #define PREFETCH prefetcht0
  68. #define PREFETCHSIZE (8 * 4)
  69. #endif
  70. #define STACKSIZE 16
  71. #define M 4 + STACKSIZE(%esp)
  72. #define N 8 + STACKSIZE(%esp)
  73. #define ALPHA_R 16 + STACKSIZE(%esp)
  74. #define ALPHA_I 24 + STACKSIZE(%esp)
  75. #define A 32 + STACKSIZE(%esp)
  76. #define STACK_LDA 36 + STACKSIZE(%esp)
  77. #define STACK_X 40 + STACKSIZE(%esp)
  78. #define STACK_INCX 44 + STACKSIZE(%esp)
  79. #define Y 48 + STACKSIZE(%esp)
  80. #define STACK_INCY 52 + STACKSIZE(%esp)
  81. #define BUFFER 56 + STACKSIZE(%esp)
  82. #define I %eax
  83. #define J %ebx
  84. #define INCX J
  85. #define INCY %ecx
  86. #define A1 %esi
  87. #define X %edx
  88. #define Y1 %edi
  89. #define LDA %ebp
  90. #undef SUBPD
  91. #ifndef CONJ
  92. #define SUBPD addpd
  93. #else
  94. #define SUBPD subpd
  95. #endif
  96. PROLOGUE
  97. pushl %ebp
  98. pushl %edi
  99. pushl %esi
  100. pushl %ebx
  101. PROFCODE
  102. movl STACK_LDA, LDA
  103. movl STACK_X, X
  104. movl STACK_INCX, INCX
  105. movl STACK_INCY, INCY
  106. sall $ZBASE_SHIFT, INCX
  107. sall $ZBASE_SHIFT, INCY
  108. sall $ZBASE_SHIFT, LDA
  109. subl $-16 * SIZE, A
  110. cmpl $0, N
  111. jle .L999
  112. cmpl $0, M
  113. jle .L999
  114. movl BUFFER, Y1
  115. movl M, I
  116. sarl $2, I
  117. jle .L05
  118. ALIGN_4
  119. .L02:
  120. movsd 0 * SIZE(X), %xmm0
  121. movhpd 1 * SIZE(X), %xmm0
  122. addl INCX, X
  123. movsd 0 * SIZE(X), %xmm1
  124. movhpd 1 * SIZE(X), %xmm1
  125. addl INCX, X
  126. movsd 0 * SIZE(X), %xmm2
  127. movhpd 1 * SIZE(X), %xmm2
  128. addl INCX, X
  129. movsd 0 * SIZE(X), %xmm3
  130. movhpd 1 * SIZE(X), %xmm3
  131. addl INCX, X
  132. movapd %xmm0, 0 * SIZE(Y1)
  133. movapd %xmm1, 2 * SIZE(Y1)
  134. movapd %xmm2, 4 * SIZE(Y1)
  135. movapd %xmm3, 6 * SIZE(Y1)
  136. addl $8 * SIZE, Y1
  137. decl I
  138. jg .L02
  139. ALIGN_4
  140. .L05:
  141. movl M, I
  142. andl $3, I
  143. jle .L10
  144. ALIGN_2
  145. .L06:
  146. movsd 0 * SIZE(X), %xmm0
  147. movhpd 1 * SIZE(X), %xmm0
  148. addl INCX, X
  149. movapd %xmm0, 0 * SIZE(Y1)
  150. addl $2 * SIZE, Y1
  151. decl I
  152. jg .L06
  153. ALIGN_4
  154. .L10:
  155. movl Y, Y1
  156. movl N, J
  157. ALIGN_3
  158. .L11:
  159. movl BUFFER, X
  160. addl $16 * SIZE, X
  161. movl A, A1
  162. addl LDA, A
  163. xorps %xmm0, %xmm0
  164. xorps %xmm1, %xmm1
  165. movapd -16 * SIZE(X), %xmm2
  166. movapd -14 * SIZE(X), %xmm3
  167. movl M, I
  168. sarl $2, I
  169. jle .L15
  170. movsd -16 * SIZE(A1), %xmm4
  171. movhpd -15 * SIZE(A1), %xmm4
  172. movsd -14 * SIZE(A1), %xmm6
  173. movhpd -13 * SIZE(A1), %xmm6
  174. decl I
  175. jle .L13
  176. ALIGN_4
  177. .L12:
  178. #ifdef PREFETCH
  179. PREFETCH PREFETCHSIZE * SIZE(A1)
  180. #endif
  181. pshufd $0x4e, %xmm4, %xmm5
  182. mulpd %xmm2, %xmm4
  183. addpd %xmm4, %xmm0
  184. movsd -12 * SIZE(A1), %xmm4
  185. movhpd -11 * SIZE(A1), %xmm4
  186. mulpd %xmm2, %xmm5
  187. SUBPD %xmm5, %xmm1
  188. movapd -12 * SIZE(X), %xmm2
  189. pshufd $0x4e, %xmm6, %xmm7
  190. mulpd %xmm3, %xmm6
  191. addpd %xmm6, %xmm0
  192. movsd -10 * SIZE(A1), %xmm6
  193. movhpd -9 * SIZE(A1), %xmm6
  194. mulpd %xmm3, %xmm7
  195. SUBPD %xmm7, %xmm1
  196. movapd -10 * SIZE(X), %xmm3
  197. pshufd $0x4e, %xmm4, %xmm5
  198. mulpd %xmm2, %xmm4
  199. addpd %xmm4, %xmm0
  200. movsd -8 * SIZE(A1), %xmm4
  201. movhpd -7 * SIZE(A1), %xmm4
  202. mulpd %xmm2, %xmm5
  203. movapd -8 * SIZE(X), %xmm2
  204. SUBPD %xmm5, %xmm1
  205. pshufd $0x4e, %xmm6, %xmm7
  206. mulpd %xmm3, %xmm6
  207. addpd %xmm6, %xmm0
  208. movsd -6 * SIZE(A1), %xmm6
  209. movhpd -5 * SIZE(A1), %xmm6
  210. mulpd %xmm3, %xmm7
  211. movapd -6 * SIZE(X), %xmm3
  212. SUBPD %xmm7, %xmm1
  213. addl $8 * SIZE, A1
  214. addl $8 * SIZE, X
  215. decl I
  216. jg .L12
  217. ALIGN_4
  218. .L13:
  219. pshufd $0x4e, %xmm4, %xmm5
  220. mulpd %xmm2, %xmm4
  221. addpd %xmm4, %xmm0
  222. movsd -12 * SIZE(A1), %xmm4
  223. movhpd -11 * SIZE(A1), %xmm4
  224. mulpd %xmm2, %xmm5
  225. SUBPD %xmm5, %xmm1
  226. movapd -12 * SIZE(X), %xmm2
  227. pshufd $0x4e, %xmm6, %xmm7
  228. mulpd %xmm3, %xmm6
  229. addpd %xmm6, %xmm0
  230. movsd -10 * SIZE(A1), %xmm6
  231. movhpd -9 * SIZE(A1), %xmm6
  232. mulpd %xmm3, %xmm7
  233. SUBPD %xmm7, %xmm1
  234. movapd -10 * SIZE(X), %xmm3
  235. pshufd $0x4e, %xmm4, %xmm5
  236. mulpd %xmm2, %xmm4
  237. addpd %xmm4, %xmm0
  238. mulpd %xmm2, %xmm5
  239. movapd -8 * SIZE(X), %xmm2
  240. SUBPD %xmm5, %xmm1
  241. pshufd $0x4e, %xmm6, %xmm7
  242. mulpd %xmm3, %xmm6
  243. addpd %xmm6, %xmm0
  244. mulpd %xmm3, %xmm7
  245. movapd -6 * SIZE(X), %xmm3
  246. SUBPD %xmm7, %xmm1
  247. addl $8 * SIZE, A1
  248. addl $8 * SIZE, X
  249. ALIGN_4
  250. .L15:
  251. testl $2, M
  252. jle .L17
  253. movsd -16 * SIZE(A1), %xmm4
  254. movhpd -15 * SIZE(A1), %xmm4
  255. movsd -14 * SIZE(A1), %xmm6
  256. movhpd -13 * SIZE(A1), %xmm6
  257. pshufd $0x4e, %xmm4, %xmm5
  258. mulpd %xmm2, %xmm4
  259. addpd %xmm4, %xmm0
  260. mulpd %xmm2, %xmm5
  261. movapd -12 * SIZE(X), %xmm2
  262. SUBPD %xmm5, %xmm1
  263. pshufd $0x4e, %xmm6, %xmm7
  264. mulpd %xmm3, %xmm6
  265. addpd %xmm6, %xmm0
  266. mulpd %xmm3, %xmm7
  267. SUBPD %xmm7, %xmm1
  268. addl $4 * SIZE, A1
  269. ALIGN_4
  270. .L17:
  271. testl $1, M
  272. jle .L18
  273. movsd -16 * SIZE(A1), %xmm4
  274. movhpd -15 * SIZE(A1), %xmm4
  275. pshufd $0x4e, %xmm4, %xmm5
  276. mulpd %xmm2, %xmm4
  277. addpd %xmm4, %xmm0
  278. mulpd %xmm2, %xmm5
  279. SUBPD %xmm5, %xmm1
  280. ALIGN_4
  281. .L18:
  282. pcmpeqb %xmm5, %xmm5
  283. psllq $63, %xmm5
  284. shufps $0xc0, %xmm5, %xmm5
  285. #if (!defined(CONJ) && !defined(XCONJ)) || (defined(CONJ) && defined(XCONJ))
  286. xorpd %xmm5, %xmm0
  287. #else
  288. xorpd %xmm5, %xmm1
  289. #endif
  290. #ifdef HAVE_SSE3
  291. haddpd %xmm1, %xmm0
  292. #else
  293. movapd %xmm0, %xmm2
  294. unpcklpd %xmm1, %xmm0
  295. unpckhpd %xmm1, %xmm2
  296. addpd %xmm2, %xmm0
  297. #endif
  298. pshufd $0x4e, %xmm0, %xmm1
  299. #ifdef HAVE_SSE3
  300. movddup ALPHA_R, %xmm6
  301. movddup ALPHA_I, %xmm7
  302. #else
  303. movsd ALPHA_R, %xmm6
  304. movsd ALPHA_I, %xmm7
  305. unpcklpd %xmm6, %xmm6
  306. unpcklpd %xmm7, %xmm7
  307. #endif
  308. mulpd %xmm6, %xmm0
  309. mulpd %xmm7, %xmm1
  310. xorpd %xmm5, %xmm1
  311. subpd %xmm1, %xmm0
  312. movsd 0 * SIZE(Y1), %xmm4
  313. movhpd 1 * SIZE(Y1), %xmm4
  314. addpd %xmm4, %xmm0
  315. movlpd %xmm0, 0 * SIZE(Y1)
  316. movhpd %xmm0, 1 * SIZE(Y1)
  317. addl INCY, Y1
  318. decl J
  319. jg .L11
  320. ALIGN_4
  321. .L999:
  322. popl %ebx
  323. popl %esi
  324. popl %edi
  325. popl %ebp
  326. ret
  327. EPILOGUE