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 5.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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
  41. #define X ARG2
  42. #define INCX ARG3
  43. #define I %rax
  44. #ifndef USE_MIN
  45. #define FMOV fcmovbe
  46. #else
  47. #define FMOV fcmovnbe
  48. #endif
  49. #include "l1param.h"
  50. PROLOGUE
  51. PROFCODE
  52. salq $BASE_SHIFT, INCX
  53. fldz
  54. testq M, M
  55. jle .L999
  56. testq INCX, INCX
  57. jle .L999
  58. ffreep %st
  59. FLD (X)
  60. #ifdef USE_ABS
  61. fabs
  62. #endif
  63. addq INCX, X
  64. decq M
  65. jle .L999
  66. cmpq $SIZE, INCX
  67. jne .L40
  68. movq M, I
  69. sarq $3, I
  70. jle .L20
  71. ALIGN_4
  72. .L10:
  73. #ifdef PREFETCH
  74. PREFETCH (PREFETCHSIZE + 0) - PREOFFSET(X)
  75. #endif
  76. FLD 0 * SIZE(X)
  77. #ifdef USE_ABS
  78. fabs
  79. #endif
  80. fcomi
  81. FMOV %st(1), %st(0)
  82. fxch %st(1)
  83. ffreep %st
  84. FLD 1 * SIZE(X)
  85. #ifdef USE_ABS
  86. fabs
  87. #endif
  88. fcomi
  89. FMOV %st(1), %st(0)
  90. fxch %st(1)
  91. ffreep %st
  92. FLD 2 * SIZE(X)
  93. #ifdef USE_ABS
  94. fabs
  95. #endif
  96. fcomi
  97. FMOV %st(1), %st(0)
  98. fxch %st(1)
  99. ffreep %st
  100. FLD 3 * SIZE(X)
  101. #ifdef USE_ABS
  102. fabs
  103. #endif
  104. fcomi
  105. FMOV %st(1), %st(0)
  106. fxch %st(1)
  107. ffreep %st
  108. FLD 4 * SIZE(X)
  109. #ifdef USE_ABS
  110. fabs
  111. #endif
  112. fcomi
  113. FMOV %st(1), %st(0)
  114. fxch %st(1)
  115. ffreep %st
  116. FLD 5 * SIZE(X)
  117. #ifdef USE_ABS
  118. fabs
  119. #endif
  120. fcomi
  121. FMOV %st(1), %st(0)
  122. fxch %st(1)
  123. ffreep %st
  124. FLD 6 * SIZE(X)
  125. #ifdef USE_ABS
  126. fabs
  127. #endif
  128. fcomi
  129. FMOV %st(1), %st(0)
  130. fxch %st(1)
  131. ffreep %st
  132. FLD 7 * SIZE(X)
  133. #ifdef USE_ABS
  134. fabs
  135. #endif
  136. fcomi
  137. FMOV %st(1), %st(0)
  138. fxch %st(1)
  139. ffreep %st
  140. addq $8 * SIZE, X
  141. decq I
  142. jg .L10
  143. ALIGN_4
  144. .L20:
  145. movq M, I
  146. andq $7, I
  147. jle .L999
  148. ALIGN_4
  149. .L21:
  150. FLD 0 * SIZE(X)
  151. #ifdef USE_ABS
  152. fabs
  153. #endif
  154. fcomi
  155. FMOV %st(1), %st(0)
  156. fxch %st(1)
  157. ffreep %st
  158. addq $1 * SIZE, X
  159. decq I
  160. jg .L21
  161. jmp .L999
  162. ALIGN_4
  163. .L40:
  164. movq M, I
  165. sarq $3, I
  166. jle .L60
  167. ALIGN_4
  168. .L50:
  169. FLD 0 * SIZE(X)
  170. addq INCX, X
  171. #ifdef USE_ABS
  172. fabs
  173. #endif
  174. fcomi
  175. FMOV %st(1), %st(0)
  176. fxch %st(1)
  177. ffreep %st
  178. FLD 0 * SIZE(X)
  179. addq INCX, X
  180. #ifdef USE_ABS
  181. fabs
  182. #endif
  183. fcomi
  184. FMOV %st(1), %st(0)
  185. fxch %st(1)
  186. ffreep %st
  187. FLD 0 * SIZE(X)
  188. addq INCX, X
  189. #ifdef USE_ABS
  190. fabs
  191. #endif
  192. fcomi
  193. FMOV %st(1), %st(0)
  194. fxch %st(1)
  195. ffreep %st
  196. FLD 0 * SIZE(X)
  197. addq INCX, X
  198. #ifdef USE_ABS
  199. fabs
  200. #endif
  201. fcomi
  202. FMOV %st(1), %st(0)
  203. fxch %st(1)
  204. ffreep %st
  205. FLD 0 * SIZE(X)
  206. addq INCX, X
  207. #ifdef USE_ABS
  208. fabs
  209. #endif
  210. fcomi
  211. FMOV %st(1), %st(0)
  212. fxch %st(1)
  213. ffreep %st
  214. FLD 0 * SIZE(X)
  215. addq INCX, X
  216. #ifdef USE_ABS
  217. fabs
  218. #endif
  219. fcomi
  220. FMOV %st(1), %st(0)
  221. fxch %st(1)
  222. ffreep %st
  223. FLD 0 * SIZE(X)
  224. addq INCX, X
  225. #ifdef USE_ABS
  226. fabs
  227. #endif
  228. fcomi
  229. FMOV %st(1), %st(0)
  230. fxch %st(1)
  231. ffreep %st
  232. FLD 0 * SIZE(X)
  233. addq INCX, X
  234. #ifdef USE_ABS
  235. fabs
  236. #endif
  237. fcomi
  238. FMOV %st(1), %st(0)
  239. fxch %st(1)
  240. ffreep %st
  241. decq I
  242. jg .L50
  243. ALIGN_4
  244. .L60:
  245. movq M, I
  246. andq $7, I
  247. jle .L999
  248. ALIGN_4
  249. .L61:
  250. FLD 0 * SIZE(X)
  251. #ifdef USE_ABS
  252. fabs
  253. #endif
  254. fcomi
  255. FMOV %st(1), %st(0)
  256. fxch %st(1)
  257. ffreep %st
  258. addq INCX, X
  259. decq I
  260. jg .L61
  261. ALIGN_4
  262. .L999:
  263. ret
  264. EPILOGUE