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_sse2.S 7.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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 maxpd minpd
  55. #define maxsd minsd
  56. #endif
  57. #include "l1param.h"
  58. PROLOGUE
  59. pushl %ebp
  60. pushl %edi
  61. pushl %esi
  62. pushl %ebx
  63. PROFCODE
  64. movl STACK_M, M
  65. movl STACK_X, X
  66. movl STACK_INCX, INCX
  67. pxor %xmm0, %xmm0
  68. pxor %xmm7, %xmm7
  69. xor RET, RET
  70. testl M, M
  71. jle .L999
  72. testl INCX, INCX
  73. jle .L999
  74. sall $ZBASE_SHIFT, INCX
  75. movl M, MM
  76. movl X, XX
  77. cmpeqpd %xmm7, %xmm7
  78. psrlq $1, %xmm7
  79. movsd 0 * SIZE(XX), %xmm0
  80. movsd 1 * SIZE(XX), %xmm1
  81. addl INCX, XX
  82. decl MM
  83. andpd %xmm7, %xmm0
  84. andpd %xmm7, %xmm1
  85. addpd %xmm1, %xmm0
  86. unpcklpd %xmm0, %xmm0
  87. cmpl $2 * SIZE, INCX
  88. jne .L60
  89. movl MM, I
  90. sarl $3, I
  91. jle .L25
  92. ALIGN_4
  93. .L21:
  94. #ifdef PREFETCH
  95. PREFETCH (PREFETCHSIZE + 0) - PREOFFSET(XX)
  96. #endif
  97. movsd 0 * SIZE(XX), %xmm1
  98. movsd 1 * SIZE(XX), %xmm2
  99. movhpd 2 * SIZE(XX), %xmm1
  100. movhpd 3 * SIZE(XX), %xmm2
  101. andpd %xmm7, %xmm1
  102. andpd %xmm7, %xmm2
  103. addpd %xmm2, %xmm1
  104. maxpd %xmm1, %xmm0
  105. movsd 4 * SIZE(XX), %xmm3
  106. movsd 5 * SIZE(XX), %xmm4
  107. movhpd 6 * SIZE(XX), %xmm3
  108. movhpd 7 * SIZE(XX), %xmm4
  109. andpd %xmm7, %xmm3
  110. andpd %xmm7, %xmm4
  111. addpd %xmm4, %xmm3
  112. maxpd %xmm3, %xmm0
  113. #if defined(PREFETCH) && !defined(FETCH128)
  114. PREFETCH (PREFETCHSIZE + 64) - PREOFFSET(XX)
  115. #endif
  116. movsd 8 * SIZE(XX), %xmm1
  117. movsd 9 * SIZE(XX), %xmm2
  118. movhpd 10 * SIZE(XX), %xmm1
  119. movhpd 11 * SIZE(XX), %xmm2
  120. andpd %xmm7, %xmm1
  121. andpd %xmm7, %xmm2
  122. addpd %xmm2, %xmm1
  123. maxpd %xmm1, %xmm0
  124. movsd 12 * SIZE(XX), %xmm3
  125. movsd 13 * SIZE(XX), %xmm4
  126. movhpd 14 * SIZE(XX), %xmm3
  127. movhpd 15 * SIZE(XX), %xmm4
  128. andpd %xmm7, %xmm3
  129. andpd %xmm7, %xmm4
  130. addpd %xmm4, %xmm3
  131. maxpd %xmm3, %xmm0
  132. addl $16 * SIZE, XX
  133. decl I
  134. jg .L21
  135. ALIGN_4
  136. .L25:
  137. andl $7, MM
  138. jle .L30
  139. testl $4, MM
  140. je .L26
  141. movsd 0 * SIZE(XX), %xmm1
  142. movsd 1 * SIZE(XX), %xmm2
  143. movhpd 2 * SIZE(XX), %xmm1
  144. movhpd 3 * SIZE(XX), %xmm2
  145. andpd %xmm7, %xmm1
  146. andpd %xmm7, %xmm2
  147. addpd %xmm2, %xmm1
  148. maxpd %xmm1, %xmm0
  149. movsd 4 * SIZE(XX), %xmm3
  150. movsd 5 * SIZE(XX), %xmm4
  151. movhpd 6 * SIZE(XX), %xmm3
  152. movhpd 7 * SIZE(XX), %xmm4
  153. andpd %xmm7, %xmm3
  154. andpd %xmm7, %xmm4
  155. addpd %xmm4, %xmm3
  156. maxpd %xmm3, %xmm0
  157. addl $8 * SIZE, XX
  158. ALIGN_3
  159. .L26:
  160. testl $2, MM
  161. je .L27
  162. movsd 0 * SIZE(XX), %xmm1
  163. movsd 1 * SIZE(XX), %xmm2
  164. movhpd 2 * SIZE(XX), %xmm1
  165. movhpd 3 * SIZE(XX), %xmm2
  166. andpd %xmm7, %xmm1
  167. andpd %xmm7, %xmm2
  168. addpd %xmm2, %xmm1
  169. maxpd %xmm1, %xmm0
  170. addl $4 * SIZE, XX
  171. ALIGN_3
  172. .L27:
  173. testl $1, MM
  174. je .L30
  175. movsd 0 * SIZE(XX), %xmm1
  176. movsd 1 * SIZE(XX), %xmm2
  177. andpd %xmm7, %xmm1
  178. andpd %xmm7, %xmm2
  179. addpd %xmm2, %xmm1
  180. maxsd %xmm1, %xmm0
  181. ALIGN_4
  182. .L30:
  183. movapd %xmm0, %xmm1
  184. unpckhpd %xmm0, %xmm0
  185. maxsd %xmm1, %xmm0
  186. jmp .L999
  187. ALIGN_3
  188. .L60:
  189. movl MM, I
  190. sarl $3, I
  191. jle .L65
  192. ALIGN_4
  193. .L61:
  194. #ifdef PREFETCH
  195. PREFETCH (PREFETCHSIZE + 0) - PREOFFSET(XX)
  196. #endif
  197. movsd 0 * SIZE(XX), %xmm1
  198. movsd 1 * SIZE(XX), %xmm2
  199. addl INCX, XX
  200. movhpd 0 * SIZE(XX), %xmm1
  201. movhpd 1 * SIZE(XX), %xmm2
  202. addl INCX, XX
  203. andpd %xmm7, %xmm1
  204. andpd %xmm7, %xmm2
  205. addpd %xmm2, %xmm1
  206. maxpd %xmm1, %xmm0
  207. movsd 0 * SIZE(XX), %xmm3
  208. movsd 1 * SIZE(XX), %xmm4
  209. addl INCX, XX
  210. movhpd 0 * SIZE(XX), %xmm3
  211. movhpd 1 * SIZE(XX), %xmm4
  212. addl INCX, XX
  213. andpd %xmm7, %xmm3
  214. andpd %xmm7, %xmm4
  215. addpd %xmm4, %xmm3
  216. maxpd %xmm3, %xmm0
  217. #ifdef PREFETCH
  218. PREFETCH (PREFETCHSIZE + 0) - PREOFFSET(XX)
  219. #endif
  220. movsd 0 * SIZE(XX), %xmm1
  221. movsd 1 * SIZE(XX), %xmm2
  222. addl INCX, XX
  223. movhpd 0 * SIZE(XX), %xmm1
  224. movhpd 1 * SIZE(XX), %xmm2
  225. addl INCX, XX
  226. andpd %xmm7, %xmm1
  227. andpd %xmm7, %xmm2
  228. addpd %xmm2, %xmm1
  229. maxpd %xmm1, %xmm0
  230. movsd 0 * SIZE(XX), %xmm3
  231. movsd 1 * SIZE(XX), %xmm4
  232. addl INCX, XX
  233. movhpd 0 * SIZE(XX), %xmm3
  234. movhpd 1 * SIZE(XX), %xmm4
  235. addl INCX, XX
  236. andpd %xmm7, %xmm3
  237. andpd %xmm7, %xmm4
  238. addpd %xmm4, %xmm3
  239. maxpd %xmm3, %xmm0
  240. decl I
  241. jg .L61
  242. ALIGN_4
  243. .L65:
  244. andl $7, MM
  245. jle .L70
  246. testl $4, MM
  247. je .L66
  248. movsd 0 * SIZE(XX), %xmm1
  249. movsd 1 * SIZE(XX), %xmm2
  250. addl INCX, XX
  251. movhpd 0 * SIZE(XX), %xmm1
  252. movhpd 1 * SIZE(XX), %xmm2
  253. addl INCX, XX
  254. andpd %xmm7, %xmm1
  255. andpd %xmm7, %xmm2
  256. addpd %xmm2, %xmm1
  257. maxpd %xmm1, %xmm0
  258. movsd 0 * SIZE(XX), %xmm3
  259. movsd 1 * SIZE(XX), %xmm4
  260. addl INCX, XX
  261. movhpd 0 * SIZE(XX), %xmm3
  262. movhpd 1 * SIZE(XX), %xmm4
  263. addl INCX, XX
  264. andpd %xmm7, %xmm3
  265. andpd %xmm7, %xmm4
  266. addpd %xmm4, %xmm3
  267. maxpd %xmm3, %xmm0
  268. ALIGN_3
  269. .L66:
  270. testl $2, MM
  271. je .L67
  272. movsd 0 * SIZE(XX), %xmm1
  273. movsd 1 * SIZE(XX), %xmm2
  274. addl INCX, XX
  275. movhpd 0 * SIZE(XX), %xmm1
  276. movhpd 1 * SIZE(XX), %xmm2
  277. addl INCX, XX
  278. andpd %xmm7, %xmm1
  279. andpd %xmm7, %xmm2
  280. addpd %xmm2, %xmm1
  281. maxpd %xmm1, %xmm0
  282. ALIGN_3
  283. .L67:
  284. testl $1, MM
  285. je .L70
  286. movsd 0 * SIZE(XX), %xmm1
  287. movsd 1 * SIZE(XX), %xmm2
  288. andpd %xmm7, %xmm1
  289. andpd %xmm7, %xmm2
  290. addpd %xmm2, %xmm1
  291. maxsd %xmm1, %xmm0
  292. ALIGN_3
  293. .L70:
  294. movapd %xmm0, %xmm1
  295. unpckhpd %xmm0, %xmm0
  296. maxsd %xmm1, %xmm0
  297. ALIGN_4
  298. .L999:
  299. subl $8, %esp
  300. movsd %xmm0, (%esp)
  301. fldl (%esp)
  302. addl $8, %esp
  303. popl %ebx
  304. popl %esi
  305. popl %edi
  306. popl %ebp
  307. ret
  308. EPILOGUE