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

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