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.

iamax.S 9.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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], c4
  103. add X, INCX, X
  104. cmp N, 0
  105. ble .LL20
  106. FABS c4, c1
  107. FABS c4, c2
  108. mov 1, v2
  109. FABS c4, c3
  110. mov 1, v3
  111. FABS c4, 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. add I, -1, I
  127. LDF [X + 5 * SIZE], a6
  128. cmp I, 0
  129. LDF [X + 6 * SIZE], a7
  130. LDF [X + 7 * SIZE], a8
  131. ble,pt %icc, .LL12
  132. add X, 8 * SIZE, X
  133. #define PREFETCHSIZE 40
  134. .LL11:
  135. FABS a1, t1
  136. prefetch [X + PREFETCHSIZE * SIZE], 0
  137. FABS a2, t2
  138. LDF [X + 0 * SIZE], a1
  139. FABS a3, t3
  140. LDF [X + 1 * SIZE], a2
  141. FABS a4, t4
  142. LDF [X + 2 * SIZE], a3
  143. FCMP %fcc0, t1, c1
  144. LDF [X + 3 * SIZE], a4
  145. FCMP %fcc1, t2, c2
  146. nop
  147. FCMP %fcc2, t3, c3
  148. FCMP %fcc3, t4, c4
  149. FCMOV %fcc0, t1, c1
  150. CMOV %fcc0, count, v1
  151. FCMOV %fcc1, t2, c2
  152. CMOV %fcc1, count, v2
  153. FCMOV %fcc2, t3, c3
  154. CMOV %fcc2, count, v3
  155. FCMOV %fcc3, t4, c4
  156. CMOV %fcc3, count, v4
  157. add count, 4, count
  158. FABS a5, t1
  159. LDF [X + 4 * SIZE], a5
  160. FABS a6, t2
  161. LDF [X + 5 * SIZE], a6
  162. FABS a7, t3
  163. LDF [X + 6 * SIZE], a7
  164. FABS a8, t4
  165. LDF [X + 7 * SIZE], a8
  166. FCMP %fcc0, t1, c1
  167. FCMP %fcc1, t2, c2
  168. FCMP %fcc2, t3, c3
  169. FCMP %fcc3, t4, c4
  170. FCMOV %fcc0, t1, c1
  171. nop
  172. CMOV %fcc0, count, v1
  173. add I, -1, I
  174. FCMOV %fcc1, t2, c2
  175. cmp I, 0
  176. CMOV %fcc1, count, v2
  177. add X, 8 * SIZE, X
  178. FCMOV %fcc2, t3, c3
  179. CMOV %fcc2, count, v3
  180. FCMOV %fcc3, t4, c4
  181. CMOV %fcc3, count, v4
  182. bg,pt %icc, .LL11
  183. add count, 4, count
  184. .LL12:
  185. FABS a1, t1
  186. FABS a2, t2
  187. FABS a3, t3
  188. FABS a4, t4
  189. FCMP %fcc0, t1, c1
  190. FCMP %fcc1, t2, c2
  191. FCMP %fcc2, t3, c3
  192. FCMP %fcc3, t4, c4
  193. FCMOV %fcc0, t1, c1
  194. CMOV %fcc0, count, v1
  195. FCMOV %fcc1, t2, c2
  196. CMOV %fcc1, count, v2
  197. FCMOV %fcc2, t3, c3
  198. CMOV %fcc2, count, v3
  199. FCMOV %fcc3, t4, c4
  200. CMOV %fcc3, count, v4
  201. add count, 4, count
  202. FABS a5, t1
  203. FABS a6, t2
  204. FABS a7, t3
  205. FABS a8, t4
  206. FCMP %fcc0, t1, c1
  207. FCMP %fcc1, t2, c2
  208. FCMP %fcc2, t3, c3
  209. FCMP %fcc3, t4, c4
  210. FCMOV %fcc0, t1, c1
  211. CMOV %fcc0, count, v1
  212. FCMOV %fcc1, t2, c2
  213. CMOV %fcc1, count, v2
  214. FCMOV %fcc2, t3, c3
  215. CMOV %fcc2, count, v3
  216. FCMOV %fcc3, t4, c4
  217. CMOV %fcc3, count, v4
  218. add count, 4, count
  219. .LL15:
  220. and N, 7, I
  221. cmp I, 0
  222. ble,a,pn %icc, .LL19
  223. nop
  224. .LL16:
  225. LDF [X + 0 * SIZE], a1
  226. FABS a1, t1
  227. FCMP %fcc0, t1, c1
  228. FCMOV %fcc0, t1, c1
  229. CMOV %fcc0, count, v1
  230. add I, -1, I
  231. add count, 1, count
  232. cmp I, 0
  233. bg,pt %icc, .LL16
  234. add X, 1 * SIZE, X
  235. .LL19:
  236. FCMP %fcc0, c2, c1
  237. add v2, 1, v2
  238. FCMP %fcc1, c4, c3
  239. add v3, 2, v3
  240. add v4, 3, v4
  241. FCMOV %fcc0, c2, c1
  242. CMOV %fcc0, v2, v1
  243. FCMOV %fcc1, c4, c3
  244. CMOV %fcc1, v4, v3
  245. FCMP %fcc0, c3, c1
  246. CMOV %fcc0, v3, v1
  247. .LL20:
  248. mov v1, %i0
  249. return %i7 + 8
  250. nop
  251. .LL50:
  252. sra N, 3, I
  253. cmp I, 0
  254. ble,pn %icc, .LL55
  255. nop
  256. LDF [X + 0 * SIZE], a1
  257. add X, INCX, X
  258. LDF [X + 0 * SIZE], a2
  259. add X, INCX, X
  260. LDF [X + 0 * SIZE], a3
  261. add X, INCX, X
  262. LDF [X + 0 * SIZE], a4
  263. add X, INCX, X
  264. LDF [X + 0 * SIZE], a5
  265. add X, INCX, X
  266. LDF [X + 0 * SIZE], a6
  267. add X, INCX, X
  268. add I, -1, I
  269. LDF [X + 0 * SIZE], a7
  270. cmp I, 0
  271. add X, INCX, X
  272. LDF [X + 0 * SIZE], a8
  273. ble,pt %icc, .LL52
  274. add X, INCX, X
  275. .LL51:
  276. FABS a1, t1
  277. LDF [X + 0 * SIZE], a1
  278. add X, INCX, X
  279. FABS a2, t2
  280. LDF [X + 0 * SIZE], a2
  281. add X, INCX, X
  282. FABS a3, t3
  283. LDF [X + 0 * SIZE], a3
  284. add X, INCX, X
  285. FABS a4, t4
  286. LDF [X + 0 * SIZE], a4
  287. add X, INCX, X
  288. FCMP %fcc0, t1, c1
  289. FCMP %fcc1, t2, c2
  290. FCMP %fcc2, t3, c3
  291. FCMP %fcc3, t4, c4
  292. FCMOV %fcc0, t1, c1
  293. CMOV %fcc0, count, v1
  294. FCMOV %fcc1, t2, c2
  295. CMOV %fcc1, count, v2
  296. FCMOV %fcc2, t3, c3
  297. CMOV %fcc2, count, v3
  298. FCMOV %fcc3, t4, c4
  299. CMOV %fcc3, count, v4
  300. add count, 4, count
  301. FABS a5, t1
  302. LDF [X + 0 * SIZE], a5
  303. add X, INCX, X
  304. FABS a6, t2
  305. LDF [X + 0 * SIZE], a6
  306. add X, INCX, X
  307. FABS a7, t3
  308. LDF [X + 0 * SIZE], a7
  309. add X, INCX, X
  310. FABS a8, t4
  311. LDF [X + 0 * SIZE], a8
  312. FCMP %fcc0, t1, c1
  313. FCMP %fcc1, t2, c2
  314. FCMP %fcc2, t3, c3
  315. FCMP %fcc3, t4, c4
  316. FCMOV %fcc0, t1, c1
  317. CMOV %fcc0, count, v1
  318. add I, -1, I
  319. FCMOV %fcc1, t2, c2
  320. CMOV %fcc1, count, v2
  321. cmp I, 0
  322. FCMOV %fcc2, t3, c3
  323. CMOV %fcc2, count, v3
  324. FCMOV %fcc3, t4, c4
  325. CMOV %fcc3, count, v4
  326. add count, 4, count
  327. bg,pt %icc, .LL51
  328. add X, INCX, X
  329. .LL52:
  330. FABS a1, t1
  331. FABS a2, t2
  332. FABS a3, t3
  333. FABS a4, t4
  334. FCMP %fcc0, t1, c1
  335. FCMP %fcc1, t2, c2
  336. FCMP %fcc2, t3, c3
  337. FCMP %fcc3, t4, c4
  338. FCMOV %fcc0, t1, c1
  339. CMOV %fcc0, count, v1
  340. FCMOV %fcc1, t2, c2
  341. CMOV %fcc1, count, v2
  342. FCMOV %fcc2, t3, c3
  343. CMOV %fcc2, count, v3
  344. FCMOV %fcc3, t4, c4
  345. CMOV %fcc3, count, v4
  346. add count, 4, count
  347. FABS a5, t1
  348. FABS a6, t2
  349. FABS a7, t3
  350. FABS a8, t4
  351. FCMP %fcc0, t1, c1
  352. FCMP %fcc1, t2, c2
  353. FCMP %fcc2, t3, c3
  354. FCMP %fcc3, t4, c4
  355. FCMOV %fcc0, t1, c1
  356. CMOV %fcc0, count, v1
  357. FCMOV %fcc1, t2, c2
  358. CMOV %fcc1, count, v2
  359. FCMOV %fcc2, t3, c3
  360. CMOV %fcc2, count, v3
  361. FCMOV %fcc3, t4, c4
  362. CMOV %fcc3, count, v4
  363. add count, 4, count
  364. .LL55:
  365. and N, 7, I
  366. cmp I, 0
  367. ble,a,pn %icc, .LL59
  368. nop
  369. .LL56:
  370. LDF [X + 0 * SIZE], a1
  371. FABS a1, t1
  372. FCMP %fcc0, t1, c1
  373. FCMOV %fcc0, t1, c1
  374. CMOV %fcc0, count, v1
  375. add I, -1, I
  376. add count, 1, count
  377. cmp I, 0
  378. bg,pt %icc, .LL56
  379. add X, INCX, X
  380. .LL59:
  381. FCMP %fcc0, c2, c1
  382. add v2, 1, v2
  383. FCMP %fcc1, c4, c3
  384. add v3, 2, v3
  385. add v4, 3, v4
  386. FCMOV %fcc0, c2, c1
  387. CMOV %fcc0, v2, v1
  388. FCMOV %fcc1, c4, c3
  389. CMOV %fcc1, v4, v3
  390. FCMP %fcc0, c3, c1
  391. CMOV %fcc0, v3, v1
  392. mov v1, %i0
  393. return %i7 + 8
  394. nop
  395. EPILOGUE