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.S 7.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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 N %i0
  41. #define X %i1
  42. #define INCX %i2
  43. #define I %i3
  44. #ifdef DOUBLE
  45. #define c1 %f0
  46. #define c2 %f2
  47. #define c3 %f4
  48. #define c4 %f6
  49. #define t1 %f8
  50. #define t2 %f10
  51. #define t3 %f12
  52. #define t4 %f14
  53. #define a1 %f16
  54. #define a2 %f18
  55. #define a3 %f20
  56. #define a4 %f22
  57. #define a5 %f24
  58. #define a6 %f26
  59. #define a7 %f28
  60. #define a8 %f30
  61. #else
  62. #define c1 %f0
  63. #define c2 %f1
  64. #define c3 %f2
  65. #define c4 %f3
  66. #define t1 %f4
  67. #define t2 %f5
  68. #define t3 %f6
  69. #define t4 %f7
  70. #define a1 %f8
  71. #define a2 %f9
  72. #define a3 %f10
  73. #define a4 %f11
  74. #define a5 %f12
  75. #define a6 %f13
  76. #define a7 %f14
  77. #define a8 %f15
  78. #endif
  79. #ifndef USE_MIN
  80. #define FCMOV FMOVG
  81. #else
  82. #define FCMOV FMOVL
  83. #endif
  84. PROLOGUE
  85. SAVESP
  86. FCLR(0)
  87. cmp N, 0
  88. ble .LL20
  89. nop
  90. cmp INCX, 0
  91. ble .LL20
  92. sll INCX, BASE_SHIFT, INCX
  93. add N, -1, N
  94. LDF [X], c4
  95. add X, INCX, X
  96. cmp N, 0
  97. ble .LL20
  98. FABS c4, c1
  99. FABS c4, c2
  100. FABS c4, c3
  101. FABS c4, c4
  102. cmp INCX, SIZE
  103. bne .LL50
  104. nop
  105. sra N, 3, I
  106. cmp I, 0
  107. ble,pn %icc, .LL15
  108. nop
  109. LDF [X + 0 * SIZE], a1
  110. LDF [X + 1 * SIZE], a2
  111. LDF [X + 2 * SIZE], a3
  112. LDF [X + 3 * SIZE], a4
  113. LDF [X + 4 * SIZE], a5
  114. add I, -1, I
  115. LDF [X + 5 * SIZE], a6
  116. cmp I, 0
  117. LDF [X + 6 * SIZE], a7
  118. LDF [X + 7 * SIZE], a8
  119. ble,pt %icc, .LL12
  120. add X, 8 * SIZE, X
  121. #define PREFETCHSIZE 40
  122. .LL11:
  123. prefetch [X + PREFETCHSIZE * SIZE], 0
  124. FABS a1, t1
  125. LDF [X + 0 * SIZE], a1
  126. FABS a2, t2
  127. LDF [X + 1 * SIZE], a2
  128. FABS a3, t3
  129. LDF [X + 2 * SIZE], a3
  130. FABS a4, t4
  131. LDF [X + 3 * SIZE], a4
  132. FCMP %fcc0, t1, c1
  133. FCMP %fcc1, t2, c2
  134. FCMP %fcc2, t3, c3
  135. FCMP %fcc3, t4, c4
  136. FCMOV %fcc0, t1, c1
  137. FCMOV %fcc1, t2, c2
  138. FCMOV %fcc2, t3, c3
  139. FCMOV %fcc3, t4, c4
  140. FABS a5, t1
  141. LDF [X + 4 * SIZE], a5
  142. FABS a6, t2
  143. LDF [X + 5 * SIZE], a6
  144. FABS a7, t3
  145. LDF [X + 6 * SIZE], a7
  146. FABS a8, t4
  147. LDF [X + 7 * SIZE], a8
  148. FCMP %fcc0, t1, c1
  149. FCMP %fcc1, t2, c2
  150. FCMP %fcc2, t3, c3
  151. FCMP %fcc3, t4, c4
  152. FCMOV %fcc0, t1, c1
  153. add I, -1, I
  154. FCMOV %fcc1, t2, c2
  155. cmp I, 0
  156. FCMOV %fcc2, t3, c3
  157. FCMOV %fcc3, t4, c4
  158. bg,pt %icc, .LL11
  159. add X, 8 * SIZE, X
  160. .LL12:
  161. FABS a1, t1
  162. FABS a2, t2
  163. FABS a3, t3
  164. FABS a4, t4
  165. FCMP %fcc0, t1, c1
  166. FCMP %fcc1, t2, c2
  167. FCMP %fcc2, t3, c3
  168. FCMP %fcc3, t4, c4
  169. FCMOV %fcc0, t1, c1
  170. FCMOV %fcc1, t2, c2
  171. FCMOV %fcc2, t3, c3
  172. FCMOV %fcc3, t4, c4
  173. FABS a5, t1
  174. FABS a6, t2
  175. FABS a7, t3
  176. FABS a8, t4
  177. FCMP %fcc0, t1, c1
  178. FCMP %fcc1, t2, c2
  179. FCMP %fcc2, t3, c3
  180. FCMP %fcc3, t4, c4
  181. FCMOV %fcc0, t1, c1
  182. FCMOV %fcc1, t2, c2
  183. FCMOV %fcc2, t3, c3
  184. FCMOV %fcc3, t4, c4
  185. .LL15:
  186. and N, 7, I
  187. cmp I, 0
  188. ble,a,pn %icc, .LL19
  189. nop
  190. .LL16:
  191. LDF [X + 0 * SIZE], a1
  192. FABS a1, t1
  193. FCMP %fcc0, t1, c1
  194. FCMOV %fcc0, t1, c1
  195. add I, -1, I
  196. cmp I, 0
  197. bg,pt %icc, .LL16
  198. add X, 1 * SIZE, X
  199. .LL19:
  200. FCMP %fcc0, c2, c1
  201. FCMP %fcc1, c4, c3
  202. FCMOV %fcc0, c2, c1
  203. FCMOV %fcc1, c4, c3
  204. FCMP %fcc0, c3, c1
  205. FCMOV %fcc0, c3, c1
  206. .LL20:
  207. return %i7 + 8
  208. clr %g0
  209. .LL50:
  210. sra N, 3, I
  211. cmp I, 0
  212. ble,pn %icc, .LL55
  213. nop
  214. LDF [X + 0 * SIZE], a1
  215. add X, INCX, X
  216. LDF [X + 0 * SIZE], a2
  217. add X, INCX, X
  218. LDF [X + 0 * SIZE], a3
  219. add X, INCX, X
  220. LDF [X + 0 * SIZE], a4
  221. add X, INCX, X
  222. LDF [X + 0 * SIZE], a5
  223. add X, INCX, X
  224. LDF [X + 0 * SIZE], a6
  225. add X, INCX, X
  226. add I, -1, I
  227. LDF [X + 0 * SIZE], a7
  228. cmp I, 0
  229. add X, INCX, X
  230. LDF [X + 0 * SIZE], a8
  231. ble,pt %icc, .LL52
  232. add X, INCX, X
  233. .LL51:
  234. FABS a1, t1
  235. LDF [X + 0 * SIZE], a1
  236. add X, INCX, X
  237. FABS a2, t2
  238. LDF [X + 0 * SIZE], a2
  239. add X, INCX, X
  240. FABS a3, t3
  241. LDF [X + 0 * SIZE], a3
  242. add X, INCX, X
  243. FABS a4, t4
  244. LDF [X + 0 * SIZE], a4
  245. add X, INCX, X
  246. FCMP %fcc0, t1, c1
  247. FCMP %fcc1, t2, c2
  248. FCMP %fcc2, t3, c3
  249. FCMP %fcc3, t4, c4
  250. FCMOV %fcc0, t1, c1
  251. FCMOV %fcc1, t2, c2
  252. FCMOV %fcc2, t3, c3
  253. FCMOV %fcc3, t4, c4
  254. FABS a5, t1
  255. LDF [X + 0 * SIZE], a5
  256. add X, INCX, X
  257. FABS a6, t2
  258. LDF [X + 0 * SIZE], a6
  259. add X, INCX, X
  260. FABS a7, t3
  261. LDF [X + 0 * SIZE], a7
  262. add X, INCX, X
  263. FABS a8, t4
  264. LDF [X + 0 * SIZE], a8
  265. FCMP %fcc0, t1, c1
  266. FCMP %fcc1, t2, c2
  267. FCMP %fcc2, t3, c3
  268. FCMP %fcc3, t4, c4
  269. FCMOV %fcc0, t1, c1
  270. add I, -1, I
  271. FCMOV %fcc1, t2, c2
  272. cmp I, 0
  273. FCMOV %fcc2, t3, c3
  274. FCMOV %fcc3, t4, c4
  275. bg,pt %icc, .LL51
  276. add X, INCX, X
  277. .LL52:
  278. FABS a1, t1
  279. FABS a2, t2
  280. FABS a3, t3
  281. FABS a4, t4
  282. FCMP %fcc0, t1, c1
  283. FCMP %fcc1, t2, c2
  284. FCMP %fcc2, t3, c3
  285. FCMP %fcc3, t4, c4
  286. FCMOV %fcc0, t1, c1
  287. FCMOV %fcc1, t2, c2
  288. FCMOV %fcc2, t3, c3
  289. FCMOV %fcc3, t4, c4
  290. FABS a5, t1
  291. FABS a6, t2
  292. FABS a7, t3
  293. FABS a8, t4
  294. FCMP %fcc0, t1, c1
  295. FCMP %fcc1, t2, c2
  296. FCMP %fcc2, t3, c3
  297. FCMP %fcc3, t4, c4
  298. FCMOV %fcc0, t1, c1
  299. FCMOV %fcc1, t2, c2
  300. FCMOV %fcc2, t3, c3
  301. FCMOV %fcc3, t4, c4
  302. .LL55:
  303. and N, 7, I
  304. cmp I, 0
  305. ble,a,pn %icc, .LL59
  306. nop
  307. .LL56:
  308. LDF [X + 0 * SIZE], a1
  309. FABS a1, t1
  310. FCMP %fcc0, t1, c1
  311. FCMOV %fcc0, t1, c1
  312. add I, -1, I
  313. cmp I, 0
  314. bg,pt %icc, .LL56
  315. add X, INCX, X
  316. .LL59:
  317. FCMP %fcc0, c2, c1
  318. FCMP %fcc1, c4, c3
  319. FCMOV %fcc0, c2, c1
  320. FCMOV %fcc1, c4, c3
  321. FCMP %fcc0, c3, c1
  322. FCMOV %fcc0, c3, c1
  323. return %i7 + 8
  324. clr %o0
  325. EPILOGUE