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_atom.S 8.3 kB

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