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.

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