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

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