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.

dnrm2.S 7.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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 $4
  41. #define X $5
  42. #define INCX $6
  43. #define XX $7
  44. #define I $2
  45. #define TEMP $3
  46. #define a1 $f4
  47. #define a2 $f5
  48. #define a3 $f6
  49. #define a4 $f7
  50. #define a5 $f8
  51. #define a6 $f9
  52. #define a7 $f10
  53. #define a8 $f11
  54. #define t1 $f12
  55. #define t2 $f13
  56. #define t3 $f14
  57. #define t4 $f15
  58. #define s1 $f0
  59. #define s2 $f1
  60. #define s3 $f2
  61. #define s4 $f3
  62. #define ALPHA $f16
  63. #define max $f17
  64. PROLOGUE
  65. #ifdef F_INTERFACE
  66. LDINT N, 0(N)
  67. LDINT INCX, 0(INCX)
  68. #endif
  69. blez N, .L999
  70. MTC $0, s1
  71. blez INCX, .L999
  72. dsll INCX, INCX, BASE_SHIFT
  73. move XX, X
  74. NOP
  75. LD a1, 0 * SIZE(X)
  76. daddiu N, N, -1
  77. daddu X, X, INCX
  78. FABS s1, a1
  79. blez N, .L999
  80. FABS s2, a1
  81. FABS s3, a1
  82. dsra I, N, 3
  83. blez I, .L15
  84. FABS s4, a1
  85. LD a1, 0 * SIZE(X)
  86. daddu X, X, INCX
  87. LD a2, 0 * SIZE(X)
  88. daddu X, X, INCX
  89. LD a3, 0 * SIZE(X)
  90. daddu X, X, INCX
  91. LD a4, 0 * SIZE(X)
  92. daddu X, X, INCX
  93. LD a5, 0 * SIZE(X)
  94. daddu X, X, INCX
  95. LD a6, 0 * SIZE(X)
  96. daddu X, X, INCX
  97. LD a7, 0 * SIZE(X)
  98. daddu X, X, INCX
  99. LD a8, 0 * SIZE(X)
  100. daddiu I, I, -1
  101. blez I, .L13
  102. daddu X, X, INCX
  103. .align 3
  104. .L12:
  105. FABS t1, a1
  106. LD a1, 0 * SIZE(X)
  107. FABS t2, a2
  108. daddu X, X, INCX
  109. FABS t3, a3
  110. LD a2, 0 * SIZE(X)
  111. FABS t4, a4
  112. daddu X, X, INCX
  113. CMPLT $fcc0, s1, t1
  114. LD a3, 0 * SIZE(X)
  115. CMPLT $fcc1, s2, t2
  116. daddu X, X, INCX
  117. CMPLT $fcc2, s3, t3
  118. LD a4, 0 * SIZE(X)
  119. CMPLT $fcc3, s4, t4
  120. daddu X, X, INCX
  121. CMOVT s1, t1, $fcc0
  122. CMOVT s2, t2, $fcc1
  123. CMOVT s3, t3, $fcc2
  124. CMOVT s4, t4, $fcc3
  125. FABS t1, a5
  126. LD a5, 0 * SIZE(X)
  127. FABS t2, a6
  128. daddu X, X, INCX
  129. FABS t3, a7
  130. LD a6, 0 * SIZE(X)
  131. FABS t4, a8
  132. daddu X, X, INCX
  133. CMPLT $fcc0, s1, t1
  134. LD a7, 0 * SIZE(X)
  135. CMPLT $fcc1, s2, t2
  136. daddu X, X, INCX
  137. CMPLT $fcc2, s3, t3
  138. LD a8, 0 * SIZE(X)
  139. CMPLT $fcc3, s4, t4
  140. daddu X, X, INCX
  141. CMOVT s1, t1, $fcc0
  142. daddiu I, I, -1
  143. CMOVT s2, t2, $fcc1
  144. CMOVT s3, t3, $fcc2
  145. bgtz I, .L12
  146. CMOVT s4, t4, $fcc3
  147. .align 3
  148. .L13:
  149. FABS t1, a1
  150. FABS t2, a2
  151. FABS t3, a3
  152. FABS t4, a4
  153. CMPLT $fcc0, s1, t1
  154. CMPLT $fcc1, s2, t2
  155. CMPLT $fcc2, s3, t3
  156. CMPLT $fcc3, s4, t4
  157. CMOVT s1, t1, $fcc0
  158. CMOVT s2, t2, $fcc1
  159. CMOVT s3, t3, $fcc2
  160. CMOVT s4, t4, $fcc3
  161. FABS t1, a5
  162. FABS t2, a6
  163. FABS t3, a7
  164. FABS t4, a8
  165. CMPLT $fcc0, s1, t1
  166. CMPLT $fcc1, s2, t2
  167. CMPLT $fcc2, s3, t3
  168. CMPLT $fcc3, s4, t4
  169. CMOVT s1, t1, $fcc0
  170. CMOVT s2, t2, $fcc1
  171. CMOVT s3, t3, $fcc2
  172. CMOVT s4, t4, $fcc3
  173. .align 3
  174. .L15:
  175. andi I, N, 7
  176. blez I, .L100
  177. NOP
  178. .align 3
  179. .L16:
  180. LD a1, 0 * SIZE(X)
  181. daddiu I, I, -1
  182. FABS t1, a1
  183. CMPLT $fcc0, s1, t1
  184. CMOVT s1, t1, $fcc0
  185. bgtz I, .L16
  186. daddu X, X, INCX
  187. .align 3
  188. .L100:
  189. CMPLT $fcc0, s1, s2
  190. CMPLT $fcc1, s3, s4
  191. CMOVT s1, s2, $fcc0
  192. CMOVT s3, s4, $fcc1
  193. CMPLT $fcc0, s1, s3
  194. CMOVT s1, s3, $fcc0
  195. daddiu N, N, 1
  196. lui TEMP, 0x3f80
  197. dmtc1 $0, a1
  198. mtc1 TEMP, ALPHA
  199. CMPEQ $fcc0, s1, a1
  200. bc1t $fcc0, .L999
  201. cvt.d.s ALPHA, ALPHA
  202. div.d ALPHA, ALPHA, s1
  203. MOV max, s1
  204. MOV s1, a1
  205. MOV s2, a1
  206. MOV s3, a1
  207. MOV s4, a1
  208. dsra I, N, 3
  209. blez I, .L105
  210. NOP
  211. LD a1, 0 * SIZE(XX)
  212. daddu XX, XX, INCX
  213. LD a2, 0 * SIZE(XX)
  214. daddu XX, XX, INCX
  215. LD a3, 0 * SIZE(XX)
  216. daddu XX, XX, INCX
  217. LD a4, 0 * SIZE(XX)
  218. daddu XX, XX, INCX
  219. LD a5, 0 * SIZE(XX)
  220. daddu XX, XX, INCX
  221. LD a6, 0 * SIZE(XX)
  222. daddu XX, XX, INCX
  223. LD a7, 0 * SIZE(XX)
  224. daddu XX, XX, INCX
  225. LD a8, 0 * SIZE(XX)
  226. daddiu I, I, -1
  227. blez I, .L104
  228. daddu XX, XX, INCX
  229. .align 3
  230. .L103:
  231. MUL t1, ALPHA, a1
  232. LD a1, 0 * SIZE(XX)
  233. MUL t2, ALPHA, a2
  234. daddu XX, XX, INCX
  235. MUL t3, ALPHA, a3
  236. LD a2, 0 * SIZE(XX)
  237. MUL t4, ALPHA, a4
  238. daddu XX, XX, INCX
  239. MADD s1, s1, t1, t1
  240. LD a3, 0 * SIZE(XX)
  241. MADD s2, s2, t2, t2
  242. daddu XX, XX, INCX
  243. MADD s3, s3, t3, t3
  244. LD a4, 0 * SIZE(XX)
  245. MADD s4, s4, t4, t4
  246. daddu XX, XX, INCX
  247. MUL t1, ALPHA, a5
  248. LD a5, 0 * SIZE(XX)
  249. MUL t2, ALPHA, a6
  250. daddu XX, XX, INCX
  251. MUL t3, ALPHA, a7
  252. LD a6, 0 * SIZE(XX)
  253. MUL t4, ALPHA, a8
  254. daddu XX, XX, INCX
  255. MADD s1, s1, t1, t1
  256. LD a7, 0 * SIZE(XX)
  257. MADD s2, s2, t2, t2
  258. daddu XX, XX, INCX
  259. MADD s3, s3, t3, t3
  260. LD a8, 0 * SIZE(XX)
  261. MADD s4, s4, t4, t4
  262. daddiu I, I, -1
  263. bgtz I, .L103
  264. daddu XX, XX, INCX
  265. .align 3
  266. .L104:
  267. MUL t1, ALPHA, a1
  268. MUL t2, ALPHA, a2
  269. MUL t3, ALPHA, a3
  270. MUL t4, ALPHA, a4
  271. MADD s1, s1, t1, t1
  272. MADD s2, s2, t2, t2
  273. MADD s3, s3, t3, t3
  274. MADD s4, s4, t4, t4
  275. MUL t1, ALPHA, a5
  276. MUL t2, ALPHA, a6
  277. MUL t3, ALPHA, a7
  278. MUL t4, ALPHA, a8
  279. MADD s1, s1, t1, t1
  280. MADD s2, s2, t2, t2
  281. MADD s3, s3, t3, t3
  282. MADD s4, s4, t4, t4
  283. .align 3
  284. .L105:
  285. andi I, N, 7
  286. blez I, .L998
  287. NOP
  288. .align 3
  289. .L106:
  290. LD a1, 0 * SIZE(XX)
  291. daddiu I, I, -1
  292. MUL t1, ALPHA, a1
  293. daddu XX, XX, INCX
  294. bgtz I, .L106
  295. MADD s1, s1, t1, t1
  296. .align 3
  297. .L998:
  298. ADD s1, s1, s2
  299. ADD s3, s3, s4
  300. ADD s1, s1, s3
  301. sqrt.d s1, s1
  302. j $31
  303. MUL s1, max, s1
  304. .align 3
  305. .L999:
  306. j $31
  307. NOP
  308. EPILOGUE