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.

amax_sse.S 8.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  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 M %ebx
  46. #define X %ecx
  47. #define INCX %edx
  48. #define I %eax
  49. #ifdef USE_MIN
  50. #define maxps minps
  51. #define maxss minss
  52. #endif
  53. #include "l1param.h"
  54. PROLOGUE
  55. pushl %ebp
  56. pushl %edi
  57. pushl %esi
  58. pushl %ebx
  59. PROFCODE
  60. movl STACK_M, M
  61. movl STACK_X, X
  62. movl STACK_INCX, INCX
  63. #ifdef F_INTERFACE
  64. movl (M), M
  65. movl (INCX), INCX
  66. #endif
  67. xorps %xmm0, %xmm0
  68. leal (, INCX, SIZE), INCX
  69. testl M, M
  70. jle .L999
  71. #ifdef USE_ABS
  72. #ifndef HAVE_SSE2
  73. subl $8, %esp
  74. movl $0x7fffffff, (%esp)
  75. movss (%esp), %xmm3
  76. shufps $0, %xmm3, %xmm3
  77. addl $8, %esp
  78. #else
  79. pcmpeqb %xmm3, %xmm3
  80. psrld $1, %xmm3
  81. #endif
  82. #endif
  83. movss (X), %xmm0
  84. shufps $0, %xmm0, %xmm0
  85. #ifdef USE_ABS
  86. andps %xmm3, %xmm0
  87. #endif
  88. movaps %xmm0, %xmm1
  89. addl INCX, X
  90. decl M
  91. jle .L999
  92. cmpl $SIZE, INCX
  93. jne .L40
  94. subl $-32 * SIZE, X
  95. cmpl $3, M
  96. jle .L17
  97. testl $SIZE, X
  98. je .L05
  99. movss -32 * SIZE(X), %xmm4
  100. addl $SIZE, X
  101. shufps $0, %xmm4, %xmm4
  102. #ifdef USE_ABS
  103. andps %xmm3, %xmm4
  104. #endif
  105. maxps %xmm4, %xmm0
  106. decl M
  107. ALIGN_3
  108. .L05:
  109. testl $2 * SIZE, X
  110. je .L06
  111. movsd -32 * SIZE(X), %xmm4
  112. addl $2 * SIZE, X
  113. unpcklps %xmm4, %xmm4
  114. #ifdef USE_ABS
  115. andps %xmm3, %xmm4
  116. #endif
  117. maxps %xmm4, %xmm1
  118. subl $2, M
  119. ALIGN_3
  120. .L06:
  121. movl M, I
  122. sarl $5, I
  123. jle .L15
  124. movaps -32 * SIZE(X), %xmm4
  125. movaps -28 * SIZE(X), %xmm5
  126. movaps -24 * SIZE(X), %xmm6
  127. movaps -20 * SIZE(X), %xmm7
  128. decl I
  129. jle .L12
  130. ALIGN_4
  131. .L11:
  132. #ifdef PREFETCH
  133. PREFETCH (PREFETCHSIZE + 0) - PREOFFSET(X)
  134. #endif
  135. #ifdef USE_ABS
  136. andps %xmm3, %xmm4
  137. #endif
  138. maxps %xmm4, %xmm0
  139. movaps -16 * SIZE(X), %xmm4
  140. #ifdef USE_ABS
  141. andps %xmm3, %xmm5
  142. #endif
  143. maxps %xmm5, %xmm1
  144. movaps -12 * SIZE(X), %xmm5
  145. #ifdef USE_ABS
  146. andps %xmm3, %xmm6
  147. #endif
  148. maxps %xmm6, %xmm0
  149. movaps -8 * SIZE(X), %xmm6
  150. #ifdef USE_ABS
  151. andps %xmm3, %xmm7
  152. #endif
  153. maxps %xmm7, %xmm1
  154. movaps -4 * SIZE(X), %xmm7
  155. #if defined(PREFETCH) && !defined(FETCH128)
  156. PREFETCH (PREFETCHSIZE + 64) - PREOFFSET(X)
  157. #endif
  158. #ifdef USE_ABS
  159. andps %xmm3, %xmm4
  160. #endif
  161. maxps %xmm4, %xmm0
  162. movaps 0 * SIZE(X), %xmm4
  163. #ifdef USE_ABS
  164. andps %xmm3, %xmm5
  165. #endif
  166. maxps %xmm5, %xmm1
  167. movaps 4 * SIZE(X), %xmm5
  168. #ifdef USE_ABS
  169. andps %xmm3, %xmm6
  170. #endif
  171. maxps %xmm6, %xmm0
  172. movaps 8 * SIZE(X), %xmm6
  173. #ifdef USE_ABS
  174. andps %xmm3, %xmm7
  175. #endif
  176. maxps %xmm7, %xmm1
  177. movaps 12 * SIZE(X), %xmm7
  178. subl $-32 * SIZE, X
  179. decl I
  180. jg .L11
  181. ALIGN_4
  182. .L12:
  183. #ifdef USE_ABS
  184. andps %xmm3, %xmm4
  185. #endif
  186. maxps %xmm4, %xmm0
  187. movaps -16 * SIZE(X), %xmm4
  188. #ifdef USE_ABS
  189. andps %xmm3, %xmm5
  190. #endif
  191. maxps %xmm5, %xmm1
  192. movaps -12 * SIZE(X), %xmm5
  193. #ifdef USE_ABS
  194. andps %xmm3, %xmm6
  195. #endif
  196. maxps %xmm6, %xmm0
  197. movaps -8 * SIZE(X), %xmm6
  198. #ifdef USE_ABS
  199. andps %xmm3, %xmm7
  200. #endif
  201. maxps %xmm7, %xmm1
  202. movaps -4 * SIZE(X), %xmm7
  203. #ifdef USE_ABS
  204. andps %xmm3, %xmm4
  205. #endif
  206. maxps %xmm4, %xmm0
  207. #ifdef USE_ABS
  208. andps %xmm3, %xmm5
  209. #endif
  210. maxps %xmm5, %xmm1
  211. #ifdef USE_ABS
  212. andps %xmm3, %xmm6
  213. #endif
  214. maxps %xmm6, %xmm0
  215. #ifdef USE_ABS
  216. andps %xmm3, %xmm7
  217. #endif
  218. maxps %xmm7, %xmm1
  219. subl $-32 * SIZE, X
  220. ALIGN_3
  221. .L15:
  222. testl $16, M
  223. je .L16
  224. movaps -32 * SIZE(X), %xmm4
  225. #ifdef USE_ABS
  226. andps %xmm3, %xmm4
  227. #endif
  228. maxps %xmm4, %xmm0
  229. movaps -28 * SIZE(X), %xmm5
  230. #ifdef USE_ABS
  231. andps %xmm3, %xmm5
  232. #endif
  233. maxps %xmm5, %xmm1
  234. movaps -24 * SIZE(X), %xmm6
  235. #ifdef USE_ABS
  236. andps %xmm3, %xmm6
  237. #endif
  238. maxps %xmm6, %xmm0
  239. movaps -20 * SIZE(X), %xmm7
  240. #ifdef USE_ABS
  241. andps %xmm3, %xmm7
  242. #endif
  243. maxps %xmm7, %xmm1
  244. addl $16 * SIZE, X
  245. ALIGN_3
  246. .L16:
  247. testl $8, M
  248. je .L17
  249. movaps -32 * SIZE(X), %xmm4
  250. #ifdef USE_ABS
  251. andps %xmm3, %xmm4
  252. #endif
  253. maxps %xmm4, %xmm0
  254. movaps -28 * SIZE(X), %xmm5
  255. #ifdef USE_ABS
  256. andps %xmm3, %xmm5
  257. #endif
  258. maxps %xmm5, %xmm1
  259. addl $8 * SIZE, X
  260. ALIGN_3
  261. .L17:
  262. testl $4, M
  263. je .L18
  264. movaps -32 * SIZE(X), %xmm4
  265. #ifdef USE_ABS
  266. andps %xmm3, %xmm4
  267. #endif
  268. maxps %xmm4, %xmm0
  269. addl $4 * SIZE, X
  270. ALIGN_3
  271. .L18:
  272. testl $2, M
  273. je .L19
  274. movsd -32 * SIZE(X), %xmm4
  275. unpcklps %xmm4, %xmm4
  276. #ifdef USE_ABS
  277. andps %xmm3, %xmm4
  278. #endif
  279. maxps %xmm4, %xmm1
  280. addl $2 * SIZE, X
  281. ALIGN_3
  282. .L19:
  283. testl $1, M
  284. je .L998
  285. movss -32 * SIZE(X), %xmm4
  286. #ifdef USE_ABS
  287. andps %xmm3, %xmm4
  288. #endif
  289. maxss %xmm4, %xmm0
  290. jmp .L998
  291. ALIGN_3
  292. .L40:
  293. movl M, I
  294. sarl $3, I
  295. jle .L45
  296. ALIGN_4
  297. .L41:
  298. movss (X), %xmm4
  299. addl INCX, X
  300. #ifdef USE_ABS
  301. andps %xmm3, %xmm4
  302. #endif
  303. maxss %xmm4, %xmm0
  304. movss (X), %xmm5
  305. addl INCX, X
  306. #ifdef USE_ABS
  307. andps %xmm3, %xmm5
  308. #endif
  309. maxss %xmm5, %xmm1
  310. movss (X), %xmm6
  311. addl INCX, X
  312. #ifdef USE_ABS
  313. andps %xmm3, %xmm6
  314. #endif
  315. maxss %xmm6, %xmm0
  316. movss (X), %xmm7
  317. addl INCX, X
  318. #ifdef USE_ABS
  319. andps %xmm3, %xmm7
  320. #endif
  321. maxss %xmm7, %xmm1
  322. movss (X), %xmm4
  323. addl INCX, X
  324. #ifdef USE_ABS
  325. andps %xmm3, %xmm4
  326. #endif
  327. maxss %xmm4, %xmm0
  328. movss (X), %xmm5
  329. addl INCX, X
  330. #ifdef USE_ABS
  331. andps %xmm3, %xmm5
  332. #endif
  333. maxss %xmm5, %xmm1
  334. movss (X), %xmm6
  335. addl INCX, X
  336. #ifdef USE_ABS
  337. andps %xmm3, %xmm6
  338. #endif
  339. maxss %xmm6, %xmm0
  340. movss (X), %xmm7
  341. addl INCX, X
  342. #ifdef USE_ABS
  343. andps %xmm3, %xmm7
  344. #endif
  345. maxss %xmm7, %xmm1
  346. decl I
  347. jg .L41
  348. ALIGN_4
  349. .L45:
  350. testl $4, M
  351. je .L46
  352. movss (X), %xmm4
  353. addl INCX, X
  354. #ifdef USE_ABS
  355. andps %xmm3, %xmm4
  356. #endif
  357. maxss %xmm4, %xmm0
  358. movss (X), %xmm5
  359. addl INCX, X
  360. #ifdef USE_ABS
  361. andps %xmm3, %xmm5
  362. #endif
  363. maxss %xmm5, %xmm1
  364. movss (X), %xmm6
  365. addl INCX, X
  366. #ifdef USE_ABS
  367. andps %xmm3, %xmm6
  368. #endif
  369. maxss %xmm6, %xmm0
  370. movss (X), %xmm7
  371. addl INCX, X
  372. #ifdef USE_ABS
  373. andps %xmm3, %xmm7
  374. #endif
  375. maxss %xmm7, %xmm1
  376. ALIGN_3
  377. .L46:
  378. testl $2, M
  379. je .L47
  380. movss (X), %xmm4
  381. addl INCX, X
  382. #ifdef USE_ABS
  383. andps %xmm3, %xmm4
  384. #endif
  385. maxss %xmm4, %xmm0
  386. movss (X), %xmm5
  387. addl INCX, X
  388. #ifdef USE_ABS
  389. andps %xmm3, %xmm5
  390. #endif
  391. maxss %xmm5, %xmm1
  392. ALIGN_3
  393. .L47:
  394. testl $1, M
  395. je .L998
  396. movss (X), %xmm4
  397. addl INCX, X
  398. #ifdef USE_ABS
  399. andps %xmm3, %xmm4
  400. #endif
  401. maxss %xmm4, %xmm0
  402. ALIGN_4
  403. .L998:
  404. maxps %xmm1, %xmm0
  405. movaps %xmm0, %xmm1
  406. movhlps %xmm0, %xmm0
  407. maxps %xmm1, %xmm0
  408. movaps %xmm0, %xmm1
  409. shufps $1, %xmm0, %xmm0
  410. maxss %xmm1, %xmm0
  411. ALIGN_4
  412. .L999:
  413. subl $8, %esp
  414. movss %xmm0, (%esp)
  415. flds (%esp)
  416. addl $8, %esp
  417. popl %ebx
  418. popl %esi
  419. popl %edi
  420. popl %ebp
  421. ret
  422. EPILOGUE