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.

scal_sse2.S 11 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  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. movq 40(%rsp), X
  56. movq 48(%rsp), INCX
  57. movaps %xmm3, %xmm0
  58. #endif
  59. SAVEREGISTERS
  60. testq M, M
  61. jle .L999
  62. leaq (, INCX, SIZE), INCX
  63. xorps %xmm1, %xmm1
  64. comisd %xmm0, %xmm1
  65. jne .L100 # Alpha != ZERO
  66. jp .L100 # For Alpha = NaN
  67. /* Alpha == ZERO */
  68. cmpq $SIZE, INCX
  69. jne .L50
  70. /* INCX == 1 */
  71. testq $15, X # aligned for quad word?
  72. je .L05
  73. movsd %xmm1, 0 * SIZE(X)
  74. addq $SIZE, X
  75. decq M
  76. jle .L999
  77. ALIGN_3
  78. .L05:
  79. /* Aligned Mode */
  80. movq M, I # rcx = n
  81. sarq $4, I
  82. jle .L12
  83. ALIGN_4
  84. .L11:
  85. #ifdef PREFETCHW
  86. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(X)
  87. #endif
  88. movaps %xmm1, 0 * SIZE(X)
  89. movaps %xmm1, 2 * SIZE(X)
  90. movaps %xmm1, 4 * SIZE(X)
  91. movaps %xmm1, 6 * SIZE(X)
  92. #ifdef PREFETCHW
  93. PREFETCHW (PREFETCHSIZE + 64) - PREOFFSET(X)
  94. #endif
  95. movaps %xmm1, 8 * SIZE(X)
  96. movaps %xmm1, 10 * SIZE(X)
  97. movaps %xmm1, 12 * SIZE(X)
  98. movaps %xmm1, 14 * SIZE(X)
  99. addq $16 * SIZE, X
  100. decq I
  101. jg .L11
  102. ALIGN_4
  103. .L12:
  104. testq $15, M
  105. je .L999
  106. testq $8, M
  107. je .L13
  108. movaps %xmm1, 0 * SIZE(X)
  109. movaps %xmm1, 2 * SIZE(X)
  110. movaps %xmm1, 4 * SIZE(X)
  111. movaps %xmm1, 6 * SIZE(X)
  112. addq $8 * SIZE, X
  113. ALIGN_3
  114. .L13:
  115. testq $4, M
  116. je .L14
  117. movaps %xmm1, 0 * SIZE(X)
  118. movaps %xmm1, 2 * SIZE(X)
  119. addq $4 * SIZE, X
  120. ALIGN_3
  121. .L14:
  122. testq $2, M
  123. je .L15
  124. movaps %xmm1, 0 * SIZE(X)
  125. addq $2 * SIZE, X
  126. ALIGN_3
  127. .L15:
  128. testq $1, M
  129. je .L999
  130. movsd %xmm1, 0 * SIZE(X)
  131. jmp .L999
  132. ALIGN_4
  133. .L50:
  134. movq M, I
  135. sarq $3, I
  136. jle .L52
  137. ALIGN_4
  138. .L51:
  139. #ifdef PREFETCHW
  140. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(X)
  141. #endif
  142. movsd %xmm1, (X)
  143. addq INCX, X
  144. movsd %xmm1, (X)
  145. addq INCX, X
  146. movsd %xmm1, (X)
  147. addq INCX, X
  148. movsd %xmm1, (X)
  149. addq INCX, X
  150. movsd %xmm1, (X)
  151. addq INCX, X
  152. movsd %xmm1, (X)
  153. addq INCX, X
  154. movsd %xmm1, (X)
  155. addq INCX, X
  156. movsd %xmm1, (X)
  157. addq INCX, X
  158. decq I
  159. jg .L51
  160. ALIGN_4
  161. .L52:
  162. testq $7, M
  163. je .L999
  164. testq $4, M
  165. je .L53
  166. movsd %xmm1, (X)
  167. addq INCX, X
  168. movsd %xmm1, (X)
  169. addq INCX, X
  170. movsd %xmm1, (X)
  171. addq INCX, X
  172. movsd %xmm1, (X)
  173. addq INCX, X
  174. ALIGN_3
  175. .L53:
  176. testq $2, M
  177. je .L54
  178. movsd %xmm1, (X)
  179. addq INCX, X
  180. movsd %xmm1, (X)
  181. addq INCX, X
  182. ALIGN_3
  183. .L54:
  184. testq $1, M
  185. je .L999
  186. movsd %xmm1, (X)
  187. jmp .L999
  188. ALIGN_4
  189. /* Alpha != ZERO */
  190. .L100:
  191. unpcklpd %xmm0, %xmm0
  192. cmpq $SIZE, INCX
  193. jne .L150
  194. testq $SIZE, X
  195. je .L105
  196. movsd 0 * SIZE(X), %xmm1
  197. mulsd %xmm0, %xmm1
  198. movsd %xmm1, 0 * SIZE(X)
  199. addq $SIZE, X
  200. decq M
  201. jle .L999
  202. ALIGN_3
  203. .L105:
  204. subq $-16 * SIZE, X
  205. movq M, I # rcx = n
  206. sarq $4, I
  207. jle .L113
  208. #if defined(BARCELONA) || defined(SHANGHAI) || defined(BULLDOZER)
  209. movaps %xmm0, %xmm1
  210. mulpd -16 * SIZE(X), %xmm1
  211. movaps %xmm0, %xmm2
  212. mulpd -14 * SIZE(X), %xmm2
  213. movaps %xmm0, %xmm3
  214. mulpd -12 * SIZE(X), %xmm3
  215. movaps %xmm0, %xmm4
  216. mulpd -10 * SIZE(X), %xmm4
  217. movaps %xmm0, %xmm5
  218. mulpd -8 * SIZE(X), %xmm5
  219. movaps %xmm0, %xmm6
  220. mulpd -6 * SIZE(X), %xmm6
  221. movaps %xmm0, %xmm7
  222. mulpd -4 * SIZE(X), %xmm7
  223. movaps %xmm0, %xmm8
  224. mulpd -2 * SIZE(X), %xmm8
  225. decq I
  226. jle .L112
  227. ALIGN_4
  228. .L111:
  229. #ifdef PREFETCHW
  230. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(X)
  231. #endif
  232. movaps %xmm1, -16 * SIZE(X)
  233. movaps %xmm2, -14 * SIZE(X)
  234. movaps %xmm3, -12 * SIZE(X)
  235. movaps %xmm4, -10 * SIZE(X)
  236. movaps %xmm0, %xmm1
  237. mulpd 0 * SIZE(X), %xmm1
  238. movaps %xmm0, %xmm2
  239. mulpd 2 * SIZE(X), %xmm2
  240. movaps %xmm0, %xmm3
  241. mulpd 4 * SIZE(X), %xmm3
  242. movaps %xmm0, %xmm4
  243. mulpd 6 * SIZE(X), %xmm4
  244. #ifdef PREFETCHW
  245. PREFETCHW (PREFETCHSIZE + 64) - PREOFFSET(X)
  246. #endif
  247. movaps %xmm5, -8 * SIZE(X)
  248. movaps %xmm6, -6 * SIZE(X)
  249. movaps %xmm7, -4 * SIZE(X)
  250. movaps %xmm8, -2 * SIZE(X)
  251. movaps %xmm0, %xmm5
  252. mulpd 8 * SIZE(X), %xmm5
  253. movaps %xmm0, %xmm6
  254. mulpd 10 * SIZE(X), %xmm6
  255. movaps %xmm0, %xmm7
  256. mulpd 12 * SIZE(X), %xmm7
  257. movaps %xmm0, %xmm8
  258. mulpd 14 * SIZE(X), %xmm8
  259. subq $-16 * SIZE, X
  260. decq I
  261. jg .L111
  262. ALIGN_4
  263. .L112:
  264. movaps %xmm1, -16 * SIZE(X)
  265. movaps %xmm2, -14 * SIZE(X)
  266. movaps %xmm3, -12 * SIZE(X)
  267. movaps %xmm4, -10 * SIZE(X)
  268. movaps %xmm5, -8 * SIZE(X)
  269. movaps %xmm6, -6 * SIZE(X)
  270. movaps %xmm7, -4 * SIZE(X)
  271. movaps %xmm8, -2 * SIZE(X)
  272. #else
  273. movaps -16 * SIZE(X), %xmm1
  274. movaps -14 * SIZE(X), %xmm2
  275. movaps -12 * SIZE(X), %xmm3
  276. movaps -10 * SIZE(X), %xmm4
  277. movaps -8 * SIZE(X), %xmm5
  278. movaps -6 * SIZE(X), %xmm6
  279. movaps -4 * SIZE(X), %xmm7
  280. movaps -2 * SIZE(X), %xmm8
  281. decq I
  282. jle .L112
  283. ALIGN_4
  284. .L111:
  285. #ifdef PREFETCHW
  286. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(X)
  287. #endif
  288. mulpd %xmm0, %xmm1
  289. movaps %xmm1, -16 * SIZE(X)
  290. movaps 0 * SIZE(X), %xmm1
  291. mulpd %xmm0, %xmm2
  292. movaps %xmm2, -14 * SIZE(X)
  293. movaps 2 * SIZE(X), %xmm2
  294. mulpd %xmm0, %xmm3
  295. movaps %xmm3, -12 * SIZE(X)
  296. movaps 4 * SIZE(X), %xmm3
  297. mulpd %xmm0, %xmm4
  298. movaps %xmm4, -10 * SIZE(X)
  299. movaps 6 * SIZE(X), %xmm4
  300. #ifdef PREFETCHW
  301. PREFETCHW (PREFETCHSIZE + 64) - PREOFFSET(X)
  302. #endif
  303. mulpd %xmm0, %xmm5
  304. movaps %xmm5, -8 * SIZE(X)
  305. movaps 8 * SIZE(X), %xmm5
  306. mulpd %xmm0, %xmm6
  307. movaps %xmm6, -6 * SIZE(X)
  308. movaps 10 * SIZE(X), %xmm6
  309. mulpd %xmm0, %xmm7
  310. movaps %xmm7, -4 * SIZE(X)
  311. movaps 12 * SIZE(X), %xmm7
  312. mulpd %xmm0, %xmm8
  313. movaps %xmm8, -2 * SIZE(X)
  314. movaps 14 * SIZE(X), %xmm8
  315. subq $-16 * SIZE, X
  316. decq I
  317. jg .L111
  318. ALIGN_4
  319. .L112:
  320. mulpd %xmm0, %xmm1
  321. movaps %xmm1, -16 * SIZE(X)
  322. mulpd %xmm0, %xmm2
  323. movaps %xmm2, -14 * SIZE(X)
  324. mulpd %xmm0, %xmm3
  325. movaps %xmm3, -12 * SIZE(X)
  326. mulpd %xmm0, %xmm4
  327. movaps %xmm4, -10 * SIZE(X)
  328. mulpd %xmm0, %xmm5
  329. movaps %xmm5, -8 * SIZE(X)
  330. mulpd %xmm0, %xmm6
  331. movaps %xmm6, -6 * SIZE(X)
  332. mulpd %xmm0, %xmm7
  333. movaps %xmm7, -4 * SIZE(X)
  334. mulpd %xmm0, %xmm8
  335. movaps %xmm8, -2 * SIZE(X)
  336. #endif
  337. subq $-16 * SIZE, X
  338. ALIGN_3
  339. .L113:
  340. testq $15, M
  341. je .L999
  342. testq $8, M
  343. je .L114
  344. movaps -16 * SIZE(X), %xmm1
  345. movaps -14 * SIZE(X), %xmm2
  346. movaps -12 * SIZE(X), %xmm3
  347. movaps -10 * SIZE(X), %xmm4
  348. mulpd %xmm0, %xmm1
  349. movaps %xmm1, -16 * SIZE(X)
  350. mulpd %xmm0, %xmm2
  351. movaps %xmm2, -14 * SIZE(X)
  352. mulpd %xmm0, %xmm3
  353. movaps %xmm3, -12 * SIZE(X)
  354. mulpd %xmm0, %xmm4
  355. movaps %xmm4, -10 * SIZE(X)
  356. addq $8 * SIZE, X
  357. ALIGN_3
  358. .L114:
  359. testq $4, M
  360. je .L115
  361. movaps -16 * SIZE(X), %xmm1
  362. movaps -14 * SIZE(X), %xmm2
  363. mulpd %xmm0, %xmm1
  364. movaps %xmm1, -16 * SIZE(X)
  365. mulpd %xmm0, %xmm2
  366. movaps %xmm2, -14 * SIZE(X)
  367. addq $4 * SIZE, X
  368. ALIGN_3
  369. .L115:
  370. testq $2, M
  371. je .L116
  372. movaps -16 * SIZE(X), %xmm1
  373. mulpd %xmm0, %xmm1
  374. movaps %xmm1, -16 * SIZE(X)
  375. addq $2 * SIZE, X
  376. ALIGN_3
  377. .L116:
  378. testq $1, M
  379. je .L999
  380. movsd -16 * SIZE(X), %xmm1
  381. mulsd %xmm0, %xmm1
  382. movsd %xmm1, -16 * SIZE(X)
  383. jmp .L999
  384. ALIGN_3
  385. /* incx != 1 */
  386. .L150:
  387. movq X, XX
  388. movq M, I # rcx = n
  389. sarq $3, I # (n >> 3)
  390. jle .L152
  391. ALIGN_4
  392. .L151:
  393. #ifdef PREFETCHW
  394. PREFETCHW (PREFETCHSIZE + 64) - PREOFFSET(X)
  395. #endif
  396. movsd (X), %xmm1
  397. addq INCX, X
  398. movsd (X), %xmm2
  399. addq INCX, X
  400. movsd (X), %xmm3
  401. addq INCX, X
  402. movsd (X), %xmm4
  403. addq INCX, X
  404. movsd (X), %xmm5
  405. addq INCX, X
  406. movsd (X), %xmm6
  407. addq INCX, X
  408. movsd (X), %xmm7
  409. addq INCX, X
  410. movsd (X), %xmm8
  411. addq INCX, X
  412. mulsd %xmm0, %xmm1
  413. mulsd %xmm0, %xmm2
  414. mulsd %xmm0, %xmm3
  415. mulsd %xmm0, %xmm4
  416. mulsd %xmm0, %xmm5
  417. mulsd %xmm0, %xmm6
  418. mulsd %xmm0, %xmm7
  419. mulsd %xmm0, %xmm8
  420. movsd %xmm1, (XX)
  421. addq INCX, XX
  422. movsd %xmm2, (XX)
  423. addq INCX, XX
  424. movsd %xmm3, (XX)
  425. addq INCX, XX
  426. movsd %xmm4, (XX)
  427. addq INCX, XX
  428. movsd %xmm5, (XX)
  429. addq INCX, XX
  430. movsd %xmm6, (XX)
  431. addq INCX, XX
  432. movsd %xmm7, (XX)
  433. addq INCX, XX
  434. movsd %xmm8, (XX)
  435. addq INCX, XX
  436. decq I
  437. jg .L151
  438. ALIGN_4
  439. .L152:
  440. testq $7, M
  441. je .L999
  442. testq $4, M
  443. je .L153
  444. movsd (X), %xmm1
  445. addq INCX, X
  446. movsd (X), %xmm2
  447. addq INCX, X
  448. movsd (X), %xmm3
  449. addq INCX, X
  450. movsd (X), %xmm4
  451. addq INCX, X
  452. mulsd %xmm0, %xmm1
  453. mulsd %xmm0, %xmm2
  454. mulsd %xmm0, %xmm3
  455. mulsd %xmm0, %xmm4
  456. movsd %xmm1, (XX)
  457. addq INCX, XX
  458. movsd %xmm2, (XX)
  459. addq INCX, XX
  460. movsd %xmm3, (XX)
  461. addq INCX, XX
  462. movsd %xmm4, (XX)
  463. addq INCX, XX
  464. ALIGN_3
  465. .L153:
  466. testq $2, M
  467. je .L154
  468. movsd (X), %xmm1
  469. addq INCX, X
  470. movsd (X), %xmm2
  471. addq INCX, X
  472. mulsd %xmm0, %xmm1
  473. mulsd %xmm0, %xmm2
  474. movsd %xmm1, (XX)
  475. addq INCX, XX
  476. movsd %xmm2, (XX)
  477. addq INCX, XX
  478. ALIGN_3
  479. .L154:
  480. testq $1, M
  481. je .L999
  482. movsd (X), %xmm1
  483. mulsd %xmm0, %xmm1
  484. movsd %xmm1, (X)
  485. ALIGN_4
  486. .L999:
  487. xorq %rax, %rax
  488. RESTOREREGISTERS
  489. ret
  490. EPILOGUE