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.

zamax_sse.S 7.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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 16
  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 RET %eax
  46. #define M %ebx
  47. #define X %ecx
  48. #define INCX %edx
  49. #define I %esi
  50. #define MM %ebp
  51. #define XX %edi
  52. #define TEMP %ebx
  53. #ifdef USE_MIN
  54. #define maxps minps
  55. #define maxss minss
  56. #endif
  57. #ifndef HAVE_SSE2
  58. #define pxor xorps
  59. #define movsd movlps
  60. #endif
  61. #include "l1param.h"
  62. PROLOGUE
  63. pushl %ebp
  64. pushl %edi
  65. pushl %esi
  66. pushl %ebx
  67. PROFCODE
  68. movl STACK_M, M
  69. movl STACK_X, X
  70. movl STACK_INCX, INCX
  71. pxor %xmm0, %xmm0
  72. pxor %xmm7, %xmm7
  73. xor RET, RET
  74. testl M, M
  75. jle .L999
  76. testl INCX, INCX
  77. jle .L999
  78. sall $ZBASE_SHIFT, INCX
  79. movl M, MM
  80. movl X, XX
  81. #ifdef USE_ABS
  82. #ifndef HAVE_SSE2
  83. subl $8, %esp
  84. movl $0x7fffffff, (%esp)
  85. movss (%esp), %xmm7
  86. shufps $0, %xmm7, %xmm7
  87. addl $8, %esp
  88. #else
  89. cmpeqps %xmm7, %xmm7
  90. psrld $1, %xmm7 /* Generate USE_ABS */
  91. #endif
  92. #endif
  93. movss 0 * SIZE(XX), %xmm0
  94. movss 1 * SIZE(XX), %xmm1
  95. addl INCX, XX
  96. decl MM
  97. #ifdef USE_ABS
  98. andps %xmm7, %xmm0
  99. andps %xmm7, %xmm1
  100. #endif
  101. addps %xmm1, %xmm0
  102. shufps $0, %xmm0, %xmm0
  103. cmpl $2 * SIZE, INCX
  104. jne .L70
  105. .L30:
  106. movl MM, I
  107. sarl $3, I
  108. jle .L35
  109. ALIGN_4
  110. .L31:
  111. #ifdef PREFETCH
  112. PREFETCH (PREFETCHSIZE + 0) - PREOFFSET(XX)
  113. #endif
  114. movsd 0 * SIZE(XX), %xmm1
  115. movhps 2 * SIZE(XX), %xmm1
  116. movsd 4 * SIZE(XX), %xmm2
  117. movhps 6 * SIZE(XX), %xmm2
  118. movaps %xmm1, %xmm3
  119. shufps $0x88, %xmm2, %xmm1
  120. shufps $0xdd, %xmm2, %xmm3
  121. #ifdef USE_ABS
  122. andps %xmm7, %xmm1
  123. andps %xmm7, %xmm3
  124. addps %xmm3, %xmm1
  125. maxps %xmm1, %xmm0
  126. #endif
  127. movsd 8 * SIZE(XX), %xmm1
  128. movhps 10 * SIZE(XX), %xmm1
  129. movsd 12 * SIZE(XX), %xmm2
  130. movhps 14 * SIZE(XX), %xmm2
  131. movaps %xmm1, %xmm3
  132. shufps $0x88, %xmm2, %xmm1
  133. shufps $0xdd, %xmm2, %xmm3
  134. #ifdef USE_ABS
  135. andps %xmm7, %xmm1
  136. andps %xmm7, %xmm3
  137. #endif
  138. addps %xmm3, %xmm1
  139. maxps %xmm1, %xmm0
  140. addl $16 * SIZE, XX
  141. decl I
  142. jg .L31
  143. ALIGN_4
  144. .L35:
  145. andl $7, MM
  146. jle .L40
  147. testl $4, MM
  148. je .L36
  149. movsd 0 * SIZE(XX), %xmm1
  150. movhps 2 * SIZE(XX), %xmm1
  151. movsd 4 * SIZE(XX), %xmm2
  152. movhps 6 * SIZE(XX), %xmm2
  153. movaps %xmm1, %xmm3
  154. shufps $0x88, %xmm2, %xmm1
  155. shufps $0xdd, %xmm2, %xmm3
  156. #ifdef USE_ABS
  157. andps %xmm7, %xmm1
  158. andps %xmm7, %xmm3
  159. #endif
  160. addps %xmm3, %xmm1
  161. maxps %xmm1, %xmm0
  162. addl $8 * SIZE, XX
  163. ALIGN_3
  164. .L36:
  165. testl $2, MM
  166. je .L37
  167. movss 0 * SIZE(XX), %xmm1
  168. movss 1 * SIZE(XX), %xmm2
  169. movss 2 * SIZE(XX), %xmm3
  170. movss 3 * SIZE(XX), %xmm4
  171. #ifdef USE_ABS
  172. andps %xmm7, %xmm1
  173. andps %xmm7, %xmm2
  174. andps %xmm7, %xmm3
  175. andps %xmm7, %xmm4
  176. #endif
  177. addps %xmm2, %xmm1
  178. addps %xmm4, %xmm3
  179. maxss %xmm1, %xmm0
  180. maxss %xmm3, %xmm0
  181. addl $4 * SIZE, XX
  182. ALIGN_3
  183. .L37:
  184. testl $1, MM
  185. je .L40
  186. movss 0 * SIZE(XX), %xmm1
  187. movss 1 * SIZE(XX), %xmm2
  188. #ifdef USE_ABS
  189. andps %xmm7, %xmm1
  190. andps %xmm7, %xmm2
  191. #endif
  192. addps %xmm2, %xmm1
  193. maxss %xmm1, %xmm0
  194. ALIGN_4
  195. .L40:
  196. movaps %xmm0, %xmm1
  197. movhlps %xmm0, %xmm0
  198. maxps %xmm1, %xmm0
  199. movaps %xmm0, %xmm1
  200. shufps $1, %xmm0, %xmm0
  201. maxss %xmm1, %xmm0
  202. jmp .L999
  203. ALIGN_4
  204. .L70:
  205. movl MM, I
  206. sarl $3, I
  207. jle .L75
  208. ALIGN_4
  209. .L71:
  210. #ifdef PREFETCH
  211. PREFETCH (PREFETCHSIZE + 0) - PREOFFSET(XX)
  212. #endif
  213. movsd 0 * SIZE(XX), %xmm1
  214. addl INCX, XX
  215. movhps 0 * SIZE(XX), %xmm1
  216. addl INCX, XX
  217. movsd 0 * SIZE(XX), %xmm2
  218. addl INCX, XX
  219. movhps 0 * SIZE(XX), %xmm2
  220. addl INCX, XX
  221. movaps %xmm1, %xmm3
  222. shufps $0x88, %xmm2, %xmm1
  223. shufps $0xdd, %xmm2, %xmm3
  224. #ifdef USE_ABS
  225. andps %xmm7, %xmm1
  226. andps %xmm7, %xmm3
  227. #endif
  228. addps %xmm3, %xmm1
  229. maxps %xmm1, %xmm0
  230. movsd 0 * SIZE(XX), %xmm1
  231. addl INCX, XX
  232. movhps 0 * SIZE(XX), %xmm1
  233. addl INCX, XX
  234. movsd 0 * SIZE(XX), %xmm2
  235. addl INCX, XX
  236. movhps 0 * SIZE(XX), %xmm2
  237. addl INCX, XX
  238. movaps %xmm1, %xmm3
  239. shufps $0x88, %xmm2, %xmm1
  240. shufps $0xdd, %xmm2, %xmm3
  241. #ifdef USE_ABS
  242. andps %xmm7, %xmm1
  243. andps %xmm7, %xmm3
  244. #endif
  245. addps %xmm3, %xmm1
  246. maxps %xmm1, %xmm0
  247. decl I
  248. jg .L71
  249. ALIGN_4
  250. .L75:
  251. andl $7, MM
  252. jle .L80
  253. testl $4, MM
  254. je .L76
  255. movsd 0 * SIZE(XX), %xmm1
  256. addl INCX, XX
  257. movhps 0 * SIZE(XX), %xmm1
  258. addl INCX, XX
  259. movsd 0 * SIZE(XX), %xmm2
  260. addl INCX, XX
  261. movhps 0 * SIZE(XX), %xmm2
  262. addl INCX, XX
  263. movaps %xmm1, %xmm3
  264. shufps $0x88, %xmm2, %xmm1
  265. shufps $0xdd, %xmm2, %xmm3
  266. #ifdef USE_ABS
  267. andps %xmm7, %xmm1
  268. andps %xmm7, %xmm3
  269. #endif
  270. addps %xmm3, %xmm1
  271. maxps %xmm1, %xmm0
  272. ALIGN_3
  273. .L76:
  274. testl $2, MM
  275. je .L77
  276. movss 0 * SIZE(XX), %xmm1
  277. movss 1 * SIZE(XX), %xmm2
  278. addl INCX, XX
  279. movss 0 * SIZE(XX), %xmm3
  280. movss 1 * SIZE(XX), %xmm4
  281. addl INCX, XX
  282. #ifdef USE_ABS
  283. andps %xmm7, %xmm1
  284. andps %xmm7, %xmm2
  285. andps %xmm7, %xmm3
  286. andps %xmm7, %xmm4
  287. #endif
  288. addps %xmm2, %xmm1
  289. addps %xmm4, %xmm3
  290. maxss %xmm1, %xmm0
  291. maxss %xmm3, %xmm0
  292. ALIGN_3
  293. .L77:
  294. testl $1, MM
  295. je .L80
  296. movss 0 * SIZE(XX), %xmm1
  297. movss 1 * SIZE(XX), %xmm2
  298. #ifdef USE_ABS
  299. andps %xmm7, %xmm1
  300. andps %xmm7, %xmm2
  301. #endif
  302. addps %xmm2, %xmm1
  303. maxss %xmm1, %xmm0
  304. ALIGN_4
  305. .L80:
  306. movaps %xmm0, %xmm1
  307. movhlps %xmm0, %xmm0
  308. maxps %xmm1, %xmm0
  309. movaps %xmm0, %xmm1
  310. shufps $1, %xmm0, %xmm0
  311. maxss %xmm1, %xmm0
  312. ALIGN_4
  313. .L999:
  314. subl $8, %esp
  315. movss %xmm0, (%esp)
  316. flds (%esp)
  317. addl $8, %esp
  318. popl %ebx
  319. popl %esi
  320. popl %edi
  321. popl %ebp
  322. ret
  323. EPILOGUE