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.

zscal_atom.S 8.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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. #ifndef WINDOWS_ABI
  41. #define M ARG1
  42. #define X ARG4
  43. #define INCX ARG5
  44. #else
  45. #define M ARG1
  46. #define X ARG2
  47. #define INCX ARG3
  48. #endif
  49. #define XX %r10
  50. #define I %rax
  51. #include "l1param.h"
  52. PROLOGUE
  53. PROFCODE
  54. #ifdef WINDOWS_ABI
  55. movaps %xmm3, %xmm0
  56. movsd 40(%rsp), %xmm1
  57. movq 48(%rsp), X
  58. movq 56(%rsp), INCX
  59. #endif
  60. SAVEREGISTERS
  61. salq $ZBASE_SHIFT, INCX
  62. testq M, M
  63. jle .L999
  64. pxor %xmm15, %xmm15
  65. comisd %xmm0, %xmm15
  66. jne .L30 # Alpha_r != ZERO
  67. comisd %xmm1, %xmm15
  68. jne .L30 # Alpha_i != ZERO
  69. /* Alpha == ZERO */
  70. cmpq $2 * SIZE, INCX
  71. jne .L20
  72. movq M, I
  73. sarq $2, I
  74. jle .L12
  75. ALIGN_4
  76. .L11:
  77. movsd %xmm1, 0 * SIZE(X)
  78. movsd %xmm1, 1 * SIZE(X)
  79. movsd %xmm1, 2 * SIZE(X)
  80. movsd %xmm1, 3 * SIZE(X)
  81. movsd %xmm1, 4 * SIZE(X)
  82. movsd %xmm1, 5 * SIZE(X)
  83. movsd %xmm1, 6 * SIZE(X)
  84. movsd %xmm1, 7 * SIZE(X)
  85. addq $8 * SIZE, X
  86. decq I
  87. jg .L11
  88. ALIGN_4
  89. .L12:
  90. testq $2, M
  91. je .L14
  92. movsd %xmm1, 0 * SIZE(X)
  93. movsd %xmm1, 1 * SIZE(X)
  94. movsd %xmm1, 2 * SIZE(X)
  95. movsd %xmm1, 3 * SIZE(X)
  96. addq $4 * SIZE, X
  97. ALIGN_3
  98. .L14:
  99. testq $1, M
  100. je .L999
  101. movsd %xmm1, 0 * SIZE(X)
  102. movsd %xmm1, 1 * SIZE(X)
  103. addq $2 * SIZE, X
  104. jmp .L999
  105. ALIGN_4
  106. .L20:
  107. movq M, I # rcx = n
  108. sarq $2, I
  109. jle .L22
  110. ALIGN_4
  111. .L21:
  112. movsd %xmm1, 0 * SIZE(X)
  113. movsd %xmm1, 1 * SIZE(X)
  114. addq INCX, X
  115. movsd %xmm1, 0 * SIZE(X)
  116. movsd %xmm1, 1 * SIZE(X)
  117. addq INCX, X
  118. movsd %xmm1, 0 * SIZE(X)
  119. movsd %xmm1, 1 * SIZE(X)
  120. addq INCX, X
  121. movsd %xmm1, 0 * SIZE(X)
  122. movsd %xmm1, 1 * SIZE(X)
  123. addq INCX, X
  124. decq I
  125. jg .L21
  126. ALIGN_4
  127. .L22:
  128. testq $2, M
  129. je .L23
  130. movsd %xmm1, 0 * SIZE(X)
  131. movsd %xmm1, 1 * SIZE(X)
  132. addq INCX, X
  133. movsd %xmm1, 0 * SIZE(X)
  134. movsd %xmm1, 1 * SIZE(X)
  135. addq INCX, X
  136. ALIGN_3
  137. .L23:
  138. testq $1, M
  139. je .L999
  140. movsd %xmm1, 0 * SIZE(X)
  141. movsd %xmm1, 1 * SIZE(X)
  142. jmp .L999
  143. ALIGN_4
  144. /* Alpha != ZERO */
  145. .L30:
  146. movq X, XX
  147. movq M, I
  148. sarq $2, I
  149. jle .L35
  150. movsd 0 * SIZE(X), %xmm2
  151. movsd 1 * SIZE(X), %xmm3
  152. addq INCX, X
  153. movsd 0 * SIZE(X), %xmm6
  154. movsd 1 * SIZE(X), %xmm7
  155. addq INCX, X
  156. movaps %xmm2, %xmm4
  157. movsd 0 * SIZE(X), %xmm8
  158. mulsd %xmm0, %xmm2
  159. movaps %xmm3, %xmm5
  160. movsd 1 * SIZE(X), %xmm9
  161. mulsd %xmm1, %xmm5
  162. addq INCX, X
  163. mulsd %xmm0, %xmm3
  164. mulsd %xmm1, %xmm4
  165. subsd %xmm5, %xmm2
  166. movsd 0 * SIZE(X), %xmm10
  167. addsd %xmm4, %xmm3
  168. movsd 1 * SIZE(X), %xmm11
  169. movaps %xmm6, %xmm4
  170. mulsd %xmm0, %xmm6
  171. addq INCX, X
  172. movaps %xmm7, %xmm5
  173. mulsd %xmm1, %xmm5
  174. mulsd %xmm0, %xmm7
  175. mulsd %xmm1, %xmm4
  176. decq I
  177. jle .L32
  178. ALIGN_4
  179. .L31:
  180. #ifdef PREFETCHW
  181. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(X)
  182. #endif
  183. subsd %xmm5, %xmm6
  184. movsd %xmm2, 0 * SIZE(XX)
  185. addsd %xmm4, %xmm7
  186. movsd %xmm3, 1 * SIZE(XX)
  187. movaps %xmm8, %xmm4
  188. movsd 0 * SIZE(X), %xmm2
  189. mulsd %xmm0, %xmm8
  190. addq INCX, XX
  191. movaps %xmm9, %xmm5
  192. movsd 1 * SIZE(X), %xmm3
  193. mulsd %xmm1, %xmm5
  194. addq INCX, X
  195. mulsd %xmm0, %xmm9
  196. mulsd %xmm1, %xmm4
  197. subsd %xmm5, %xmm8
  198. movsd %xmm6, 0 * SIZE(XX)
  199. addsd %xmm4, %xmm9
  200. movsd %xmm7, 1 * SIZE(XX)
  201. movaps %xmm10, %xmm4
  202. movsd 0 * SIZE(X), %xmm6
  203. mulsd %xmm0, %xmm10
  204. addq INCX, XX
  205. movaps %xmm11, %xmm5
  206. movsd 1 * SIZE(X), %xmm7
  207. mulsd %xmm1, %xmm5
  208. addq INCX, X
  209. mulsd %xmm0, %xmm11
  210. mulsd %xmm1, %xmm4
  211. subsd %xmm5, %xmm10
  212. movsd %xmm8, 0 * SIZE(XX)
  213. addsd %xmm4, %xmm11
  214. movsd %xmm9, 1 * SIZE(XX)
  215. movaps %xmm2, %xmm4
  216. movsd 0 * SIZE(X), %xmm8
  217. mulsd %xmm0, %xmm2
  218. addq INCX, XX
  219. movaps %xmm3, %xmm5
  220. movsd 1 * SIZE(X), %xmm9
  221. mulsd %xmm1, %xmm5
  222. addq INCX, X
  223. mulsd %xmm0, %xmm3
  224. mulsd %xmm1, %xmm4
  225. subsd %xmm5, %xmm2
  226. movsd %xmm10, 0 * SIZE(XX)
  227. addsd %xmm4, %xmm3
  228. movsd %xmm11, 1 * SIZE(XX)
  229. movaps %xmm6, %xmm4
  230. movsd 0 * SIZE(X), %xmm10
  231. mulsd %xmm0, %xmm6
  232. addq INCX, XX
  233. movaps %xmm7, %xmm5
  234. movsd 1 * SIZE(X), %xmm11
  235. mulsd %xmm1, %xmm5
  236. addq INCX, X
  237. mulsd %xmm0, %xmm7
  238. mulsd %xmm1, %xmm4
  239. decq I
  240. jg .L31
  241. ALIGN_4
  242. .L32:
  243. subsd %xmm5, %xmm6
  244. movsd %xmm2, 0 * SIZE(XX)
  245. addsd %xmm4, %xmm7
  246. movsd %xmm3, 1 * SIZE(XX)
  247. movaps %xmm8, %xmm4
  248. mulsd %xmm0, %xmm8
  249. addq INCX, XX
  250. movaps %xmm9, %xmm5
  251. mulsd %xmm1, %xmm5
  252. mulsd %xmm0, %xmm9
  253. mulsd %xmm1, %xmm4
  254. subsd %xmm5, %xmm8
  255. movsd %xmm6, 0 * SIZE(XX)
  256. addsd %xmm4, %xmm9
  257. movsd %xmm7, 1 * SIZE(XX)
  258. movaps %xmm10, %xmm4
  259. mulsd %xmm0, %xmm10
  260. addq INCX, XX
  261. movaps %xmm11, %xmm5
  262. mulsd %xmm1, %xmm5
  263. mulsd %xmm0, %xmm11
  264. mulsd %xmm1, %xmm4
  265. subsd %xmm5, %xmm10
  266. movsd %xmm8, 0 * SIZE(XX)
  267. addsd %xmm4, %xmm11
  268. movsd %xmm9, 1 * SIZE(XX)
  269. addq INCX, XX
  270. movsd %xmm10, 0 * SIZE(XX)
  271. movsd %xmm11, 1 * SIZE(XX)
  272. addq INCX, XX
  273. ALIGN_3
  274. .L35:
  275. testq $2, M
  276. je .L37
  277. movsd 0 * SIZE(X), %xmm2
  278. movsd 1 * SIZE(X), %xmm3
  279. addq INCX, X
  280. movaps %xmm2, %xmm4
  281. movsd 0 * SIZE(X), %xmm6
  282. mulsd %xmm0, %xmm2
  283. movaps %xmm3, %xmm5
  284. movsd 1 * SIZE(X), %xmm7
  285. mulsd %xmm1, %xmm5
  286. addq INCX, X
  287. mulsd %xmm0, %xmm3
  288. mulsd %xmm1, %xmm4
  289. subsd %xmm5, %xmm2
  290. addsd %xmm4, %xmm3
  291. movaps %xmm6, %xmm4
  292. mulsd %xmm0, %xmm6
  293. movaps %xmm7, %xmm5
  294. mulsd %xmm1, %xmm5
  295. mulsd %xmm0, %xmm7
  296. mulsd %xmm1, %xmm4
  297. subsd %xmm5, %xmm6
  298. movsd %xmm2, 0 * SIZE(XX)
  299. addsd %xmm4, %xmm7
  300. movsd %xmm3, 1 * SIZE(XX)
  301. addq INCX, XX
  302. movsd %xmm6, 0 * SIZE(XX)
  303. movsd %xmm7, 1 * SIZE(XX)
  304. addq INCX, XX
  305. ALIGN_3
  306. .L37:
  307. testq $1, M
  308. je .L999
  309. movsd 0 * SIZE(X), %xmm2
  310. movsd 1 * SIZE(X), %xmm3
  311. movaps %xmm2, %xmm4
  312. mulsd %xmm0, %xmm2
  313. movaps %xmm3, %xmm5
  314. mulsd %xmm1, %xmm5
  315. mulsd %xmm0, %xmm3
  316. mulsd %xmm1, %xmm4
  317. subsd %xmm5, %xmm2
  318. addsd %xmm4, %xmm3
  319. movsd %xmm2, 0 * SIZE(XX)
  320. movsd %xmm3, 1 * SIZE(XX)
  321. ALIGN_3
  322. .L999:
  323. xorq %rax, %rax
  324. RESTOREREGISTERS
  325. ret
  326. EPILOGUE