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_sse.S 11 kB

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