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.

zasum_sse.S 6.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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 I %eax
  46. #define M %ecx
  47. #define X %esi
  48. #define INCX %ebx
  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. xorps %xmm0, %xmm0
  58. xorps %xmm1, %xmm1
  59. testl M, M
  60. jle .L999
  61. testl INCX, INCX
  62. jle .L999
  63. #ifdef HAVE_SSE2
  64. pcmpeqb %xmm3, %xmm3
  65. psrld $1, %xmm3
  66. #else
  67. movl $0x7fffffff, STACK_M
  68. movss STACK_M, %xmm3
  69. shufps $0, %xmm3, %xmm3
  70. #endif
  71. sall $ZBASE_SHIFT, INCX
  72. cmpl $2 * SIZE, INCX
  73. jne .L100
  74. subl $-32 * SIZE, X
  75. addl M, M
  76. cmpl $3, M
  77. jle .L18
  78. testl $4, X
  79. je .L05
  80. movss -32 * SIZE(X), %xmm0
  81. andps %xmm3, %xmm0
  82. addl $SIZE, X
  83. decl M
  84. jle .L999
  85. ALIGN_3
  86. .L05:
  87. testl $8, X
  88. je .L10
  89. movsd -32 * SIZE(X), %xmm1
  90. andps %xmm3, %xmm1
  91. addl $2 * SIZE, X
  92. subl $2, M
  93. jle .L999
  94. ALIGN_3
  95. .L10:
  96. movl M, I
  97. sarl $5, I
  98. jle .L14
  99. movaps -32 * SIZE(X), %xmm4
  100. movaps -28 * SIZE(X), %xmm5
  101. movaps -24 * SIZE(X), %xmm6
  102. movaps -20 * SIZE(X), %xmm7
  103. decl I
  104. jle .L12
  105. ALIGN_3
  106. .L11:
  107. #ifdef PREFETCH
  108. PREFETCH (PREFETCHSIZE + 0) - PREOFFSET(X)
  109. #endif
  110. andps %xmm3, %xmm4
  111. addps %xmm4, %xmm0
  112. movaps -16 * SIZE(X), %xmm4
  113. andps %xmm3, %xmm5
  114. addps %xmm5, %xmm1
  115. movaps -12 * SIZE(X), %xmm5
  116. andps %xmm3, %xmm6
  117. addps %xmm6, %xmm0
  118. movaps -8 * SIZE(X), %xmm6
  119. andps %xmm3, %xmm7
  120. addps %xmm7, %xmm1
  121. movaps -4 * SIZE(X), %xmm7
  122. #if defined(PREFETCH) && !defined(FETCH128)
  123. PREFETCH (PREFETCHSIZE + 64) - PREOFFSET(X)
  124. #endif
  125. andps %xmm3, %xmm4
  126. addps %xmm4, %xmm0
  127. movaps 0 * SIZE(X), %xmm4
  128. andps %xmm3, %xmm5
  129. addps %xmm5, %xmm1
  130. movaps 4 * SIZE(X), %xmm5
  131. andps %xmm3, %xmm6
  132. addps %xmm6, %xmm0
  133. movaps 8 * SIZE(X), %xmm6
  134. andps %xmm3, %xmm7
  135. addps %xmm7, %xmm1
  136. movaps 12 * SIZE(X), %xmm7
  137. subl $-32 * SIZE, X
  138. decl I
  139. jg .L11
  140. ALIGN_3
  141. .L12:
  142. andps %xmm3, %xmm4
  143. addps %xmm4, %xmm0
  144. movaps -16 * SIZE(X), %xmm4
  145. andps %xmm3, %xmm5
  146. addps %xmm5, %xmm1
  147. movaps -12 * SIZE(X), %xmm5
  148. andps %xmm3, %xmm6
  149. addps %xmm6, %xmm0
  150. movaps -8 * SIZE(X), %xmm6
  151. andps %xmm3, %xmm7
  152. addps %xmm7, %xmm1
  153. movaps -4 * SIZE(X), %xmm7
  154. andps %xmm3, %xmm4
  155. addps %xmm4, %xmm0
  156. andps %xmm3, %xmm5
  157. addps %xmm5, %xmm1
  158. andps %xmm3, %xmm6
  159. addps %xmm6, %xmm0
  160. andps %xmm3, %xmm7
  161. addps %xmm7, %xmm1
  162. addl $32 * SIZE, X
  163. ALIGN_3
  164. .L14:
  165. testl $16, M
  166. je .L16
  167. movaps -32 * SIZE(X), %xmm4
  168. andps %xmm3, %xmm4
  169. addps %xmm4, %xmm0
  170. movaps -28 * SIZE(X), %xmm5
  171. andps %xmm3, %xmm5
  172. addps %xmm5, %xmm1
  173. movaps -24 * SIZE(X), %xmm6
  174. andps %xmm3, %xmm6
  175. addps %xmm6, %xmm0
  176. movaps -20 * SIZE(X), %xmm7
  177. andps %xmm3, %xmm7
  178. addps %xmm7, %xmm1
  179. addl $16 * SIZE, X
  180. ALIGN_3
  181. .L16:
  182. testl $8, M
  183. je .L17
  184. movaps -32 * SIZE(X), %xmm4
  185. andps %xmm3, %xmm4
  186. addps %xmm4, %xmm0
  187. movaps -28 * SIZE(X), %xmm5
  188. andps %xmm3, %xmm5
  189. addps %xmm5, %xmm1
  190. addl $8 * SIZE, X
  191. ALIGN_3
  192. .L17:
  193. testl $4, M
  194. je .L18
  195. movaps -32 * SIZE(X), %xmm4
  196. andps %xmm3, %xmm4
  197. addps %xmm4, %xmm0
  198. addl $4 * SIZE, X
  199. ALIGN_3
  200. .L18:
  201. testl $2, M
  202. je .L19
  203. #ifdef movsd
  204. xorps %xmm4, %xmm4
  205. #endif
  206. movsd -32 * SIZE(X), %xmm4
  207. andps %xmm3, %xmm4
  208. addps %xmm4, %xmm1
  209. addl $2 * SIZE, X
  210. ALIGN_3
  211. .L19:
  212. testl $1, M
  213. je .L999
  214. movss -32 * SIZE(X), %xmm4
  215. andps %xmm3, %xmm4
  216. addps %xmm4, %xmm0
  217. jmp .L999
  218. ALIGN_4
  219. .L100:
  220. movl M, I
  221. sarl $2, I
  222. jle .L105
  223. ALIGN_4
  224. .L101:
  225. movsd (X), %xmm4
  226. addl INCX, X
  227. movhps (X), %xmm4
  228. addl INCX, X
  229. andps %xmm3, %xmm4
  230. addps %xmm4, %xmm0
  231. movsd (X), %xmm5
  232. addl INCX, X
  233. movhps (X), %xmm5
  234. addl INCX, X
  235. andps %xmm3, %xmm5
  236. addps %xmm5, %xmm1
  237. decl I
  238. jg .L101
  239. ALIGN_4
  240. .L105:
  241. #ifdef movsd
  242. xorps %xmm4, %xmm4
  243. #endif
  244. andl $3, M
  245. jle .L999
  246. ALIGN_4
  247. .L106:
  248. movsd (X), %xmm4
  249. andps %xmm3, %xmm4
  250. addps %xmm4, %xmm0
  251. addl INCX, X
  252. decl M
  253. jg .L106
  254. ALIGN_4
  255. .L999:
  256. addps %xmm1, %xmm0
  257. #ifndef HAVE_SSE3
  258. movhlps %xmm0, %xmm1
  259. addps %xmm1, %xmm0
  260. movaps %xmm0, %xmm1
  261. shufps $1, %xmm0, %xmm0
  262. addss %xmm1, %xmm0
  263. #else
  264. haddps %xmm0, %xmm0
  265. haddps %xmm0, %xmm0
  266. #endif
  267. movss %xmm0, STACK_M
  268. flds STACK_M
  269. popl %ebx
  270. popl %esi
  271. ret
  272. EPILOGUE